zend-form
zend-form copied to clipboard
Input filters on form elements are not reflected when rendered
For example setting a form element required in the input filter does not render the element with required attribute. The same happens for any validations which could be directly handled by html5.
I know I can set the attributes on the form element directly, but with this I have to maintain the same information in two separate places.
@tylkomat Right, this is not implement.
If you would like to tackle this, we would appreciate the help.
@tylkomat @froschdesign I ran into the same problem myself so I monkey patched few Form classes that I am now using using in Form builder so they build input attributes within the other Form Input features. I'd like to help with this PR if that's okay with you.
@unckleg Everyone is welcome!
Do you think it is correct to always automatically add the required attribute if the field is required?
Also, side note - sometimes the field is required, but would need a custom message. This is implemented with the NotEmpty validator. Do we need to implement it for the validator, too?
I am not a big fan of HTML 5 validation mainly because this is not consistant between browsers. Also, Message cannot be customized without javascript (see https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation#Customized_error_messages).
Should ZF automatically set the required HTML attribute, it will take a mean to... get rid of it !
Do you think it is correct to always automatically add the
requiredattribute if the field is required?
Yep
Also, side note - sometimes the field is required, but would need a custom message. This is implemented with the NotEmpty validator. Do we need to implement it for the validator, too?
While I agree that there might be some level of customisation, required being implemented via NotEmpty is a detail, and replacing the NotEmpty validator is different from just using required.
@Ocramius
Offtopic: Maybe we should think of a way of customizing the required message, because the current way of doing it via the NotEmpty validator is just a workaround. What do you think?
Not really needed for ghe HTML required attribute: browsers are generally quite clear on it
On Sun, 12 Aug 2018, 12:33 Cvetomir, [email protected] wrote:
@Ocramius https://github.com/Ocramius Offtopic: Maybe we should think of a way of customizing the required message, because the current way of doing it via the NotEmpty validator is just a workaround. What do you think?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-form/issues/182#issuecomment-412330435, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakPvMQiSYqDw6ub2VtzSN_2rDsBpTks5uP_ZtgaJpZM4QZtOH .
I meant customizing the message after the validation process in the back-end (when $form->isValid() is called), hence I added the 'offtopic'.
Otherwise, I'm okay with adding the HTML5 attribute. I will investigate and try to make a PR about it.
That can be customised by replacing the NotEmpty validator
On Sun, 12 Aug 2018, 12:45 Cvetomir, [email protected] wrote:
I meant customizing the message after the validation process in the back-end (when $form->isValid() is called), hence I added the 'offtopic'. Otherwise, I'm okay with adding the HTML5 attribute. I will investigate and try to make a PR about it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-form/issues/182#issuecomment-412330988, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakAEQ46GnURojSWKU3TiJ2LgdCECWks5uP_k8gaJpZM4QZtOH .
This repository has been closed and moved to laminas/laminas-form; a new issue has been opened at https://github.com/laminas/laminas-form/issues/9.