You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Form field filter not taken into account for frontend validation #259
As addRule(Form::PATTERN adds a HTML attribute pattern, the input of the field, which would cleanup the value to pass the pattern test is not applied before HTML5 validation in the browser, the form cannot be submitted.
Steps To Reproduce
$form->addText('code', 'Kód e-receptu')
->setRequired(true)
->addFilter(function ($value) {
return Strings::lower(Strings::trim(Strings::replace($value, '/[- ]/', '')));
})
->addRule(Form::PATTERN, 'Kód musí obsahovat právě 12 číslic nebo písmen', '/^[a-z0-9]{12}$/');
The example from the documentation will also not pass the HTML5 validation when containing spaces.
Expected Behavior
It is possible to submit the form.
Possible Solutions
The HTML5 validation is not applied on fields having a filter, the form is validated on the backend.
Activity
dg commentedon Nov 3, 2020
Looks like you haven't loaded netteforms.js
finwe commentedon Nov 3, 2020
Yes, I haven't, knowingly.
finwe commentedon Nov 3, 2020
Anyway, the filter isn't applied to the value even with netteforms.js - how could it convert the PHP closure to javascript?
breaks exporting rules to JS after non-static validator [Closes #259]
breaks exporting rules to JS after non-static validator [Closes #259]
breaks exporting rules to JS after non-static validator [Closes #259]
breaks exporting rules to JS after non-static validator [Closes #259]
breaks exporting rules to JS after non-static validator [Closes #259]
breaks exporting rules to JS after non-static validator [Closes #259]
breaks exporting rules to JS after non-static validator [Closes #259]