Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds url input type for View settings fields, converts a few settings to use it #2193

Closed
wants to merge 3 commits into from

Conversation

zackkatz
Copy link
Member

@zackkatz zackkatz commented Nov 7, 2024

This takes advantage of browser validation (related to #2159), while making a very small change.

I considered updating the GravityView_FieldType abstract class to add an input_type and just use the existing GravityView_FieldType_text class, but I determined that this was cleaner.

To test:

In the View editor, test the Delete Entry Redirect URL, No Entries Redirect URL, and Edit Entry Redirect URL settings.

  • Add URLs with special characters. Make sure they are saved and stored properly
  • Test to make sure redirections are correct

💾 Build file (cd843a7).

This takes advantage of browser validation (related to #2159), while making a very small change.

I considered updating the `GravityView_FieldType` abstract class to add an `input_type` and just use the existing `GravityView_FieldType_text` class, but I determined that this was cleaner.
I determined it wasn't necessary to let users know that URL inputs are being browser-validated now.
@mrcasual
Copy link
Collaborator

@Mwalek, please test.

@Mwalek
Copy link

Mwalek commented Nov 21, 2024

@mrcasual @zackkatz I tested the URL input type with different types of URLs to see how it handles them.

Valid URLs like https://example.com and https://192.168.1.1/settings worked fine and redirected correctly. However, it's worth pointing out that the validation isn't perfect. Some invalid URLs, like htp://example.com, https:///path, and https://example..com, were saved instead of being rejected.

Another noteworthy point is that given the new validation, it will not be possible to use user submitted data or GF default merge tags as the redirect URL. For example, the user might have a form field they want to add using a merge tag like so {User Submitted URL:1}, this will no longer be possible.

Finally, users do not get a clear textual prompt if the invalid URL is in a settings tab that they have navigated away from. In such cases, the View is not published/updated but the user does not see a message explaining why. To reproduce, add an invalid URL in the Edit Entry settings, go to a different settings tab, e.g Delete Entry settings tab, try to save your changes.

Summary

  • Some invalid URLs are saved.
  • Merge tags can’t be used for redirects.
  • No error message when invalid URLs prevent saving settings.

@rafaehlers
Copy link
Contributor

The fact that we can't use Merge Tags anymore is a no-go, I think.

@zackkatz zackkatz closed this Nov 27, 2024
@zackkatz
Copy link
Member Author

Closed due to the Merge Tag issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants