Jump to content

Form validation and field number in custom module [HelperForm]


Recommended Posts

Hello all,

 

I'm struggling with the validation of a configuration form for a custom module, I'm trying to keep the code as neat as possible.

 

I use the helperform class to generate the form, I added the required => true, but a novalidate attribute on the <form> make it useless (apart from displaying a pretty red * before the label).

 

Is there a trick I have not discovered to have a working validation with the helper class without overriding anything or doing ajax? I found nothing really interesting on the internet...

 

On a second point, how are you supposed to have a field containing only numbers with the helper class since there's no "number" type field?

 

Thank you very much for your help.

Share this post


Link to post
Share on other sites

Is it a silly question or nobody knows what to do to have a validated form with the helper?

 

If i missed something in the doc and that makes the question not worth answering, please share anyway, I would gladly admit my silliness but I need this validation working and I cannot get it to do so.

Share this post


Link to post
Share on other sites
  • 2 years later...

I also stumbled on this question and found this unanswered, so to those others whose looking for answer there's no trick to do unless you do js overriding. In 1.7, if you look to these file, adminxxxx/themes/default/template/helpers/form/form.tpl which helperform class uses when generating form, novalidate attribute is added statically, no condition, just placed there as if intentionally. So I put a  code in my js that overrides that attribute in form.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More