Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Input filters on form elements are not reflected when rendered #182

Open
tylkomat opened this issue Nov 10, 2017 · 11 comments
Open

Input filters on form elements are not reflected when rendered #182

tylkomat opened this issue Nov 10, 2017 · 11 comments

Comments

@tylkomat
Copy link

tylkomat commented Nov 10, 2017

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.

@froschdesign
Copy link
Member

@tylkomat
Right, this is not implement.

If you would like to tackle this, we would appreciate the help.

@unckleg
Copy link

unckleg commented Mar 12, 2018

@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.

@froschdesign
Copy link
Member

@unckleg
Everyone is welcome!

@thexpand
Copy link
Contributor

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?

@jcaillot
Copy link

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 !

@Ocramius
Copy link
Member

Do you think it is correct to always automatically add the required attribute 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.

@thexpand
Copy link
Contributor

@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?

@Ocramius
Copy link
Member

Ocramius commented Aug 12, 2018 via email

@thexpand
Copy link
Contributor

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.

@Ocramius
Copy link
Member

Ocramius commented Aug 12, 2018 via email

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-form; a new issue has been opened at laminas/laminas-form#9.

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

No branches or pull requests

7 participants