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

pattern property not working with url fields #4597

Closed
silllli opened this issue Aug 23, 2022 · 7 comments · Fixed by #4604
Closed

pattern property not working with url fields #4597

silllli opened this issue Aug 23, 2022 · 7 comments · Fixed by #4604
Labels
type: docs 📝 Is about documentation; adds documentation
Milestone

Comments

@silllli
Copy link
Contributor

silllli commented Aug 23, 2022

Description

The pattern property to validate input doesn’t work with url fields.

Expected behavior

Setting a regex pattern that validates user input in the panel should prevent saving differing values.

To reproduce

  1. Create a blueprint featuring a url field
  2. Set this pattern to match Vimeo links pattern: '^(http\:\/\/|https\:\/\/)?(www\.)?(vimeo\.com\/)([0-9]+)$‘
  3. Enter anything but a Vimeo url, e. g. https://getkirby.com
  4. Save the value despite not matching the pattern
someUrl:
  type: url
  pattern: '^(http\:\/\/|https\:\/\/)?(www\.)?(vimeo\.com\/)([0-9]+)$'

Your setup

Kirby Version

Your system (please complete the following information)

  • Device: MacBook Pro
  • OS: macOS 12.5.1
  • Browser: Safari
  • Version: 15.6.1

Additional context

Changing the field type to text makes the pattern validation work.

@texnixe
Copy link
Member

texnixe commented Aug 23, 2022

This is because the url field uses the minlength, maxlength and url validators, whereas the text field uses minlength, maxlength and pattern. So pattern is not supported for the url field.

@afbora
Copy link
Member

afbora commented Aug 23, 2022

@texnixe pattern prop listing for the url field. That's confusing.
https://getkirby.com/docs/reference/panel/fields/url#field-properties

@silllli
Copy link
Contributor Author

silllli commented Aug 24, 2022

@texnixe pattern prop listing for the url field. That's confusing.
https://getkirby.com/docs/reference/panel/fields/url#field-properties

That’s how I got the idea 🙂 I think it’s no problem if you have a special pattern like mine (and can use a text field instead), the docs just needed to be updated.

@afbora
Copy link
Member

afbora commented Aug 25, 2022

I think we should add the pattern prop to Unset inherited props and remove it from the documentation. What do you think?

/**
* Unset inherited props
*/
'converter' => null,
'counter' => null,
'spellcheck' => null,

@afbora afbora added the needs: discussion 🗣 Requires further discussion to proceed label Aug 25, 2022
@lukasbestle
Copy link
Member

Funny how we both looked at this issue at the same time and came to the same conclusion :D

@lukasbestle lukasbestle added this to the 3.8.0 milestone Aug 25, 2022
@lukasbestle lukasbestle linked a pull request Aug 25, 2022 that will close this issue
2 tasks
@afbora afbora added needs: docs 📝 Requires documentation and removed needs: discussion 🗣 Requires further discussion to proceed labels Aug 25, 2022
@afbora
Copy link
Member

afbora commented Aug 25, 2022

To be honest, I was also surprised when you were able to PR so fast😄

@lukasbestle
Copy link
Member

@afbora afbora added type: docs 📝 Is about documentation; adds documentation and removed needs: docs 📝 Requires documentation labels Aug 25, 2022
@afbora afbora modified the milestones: 3.8.0, 3.7.5 Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs 📝 Is about documentation; adds documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants