PHP Classes

validation: which field fail ?

Recommend this page to a friend!

      HtmlForm PHP 5  >  All threads  >  validation: which field fail ?  >  (Un) Subscribe thread alerts  
Subject:validation: which field fail ?
Summary:How to determinate which form field failed ?
Messages:2
Author:w. studer
Date:2012-01-10 14:24:43
Update:2012-01-11 09:01:40
 

  1. validation: which field fail ?   Reply   Report abuse  
Picture of w. studer w. studer - 2012-01-10 14:24:43
Hi

again me ....

I have a form with n fields.
When save, I get the nice errormessages on top with info which fields fail.

I want to set the background color of those failed fields to light red.

Questions:
1) could I do it with a setting directly in HtmlForms ? (e.g. ->setCssClassesError (xxx)

2) Is there a possibility to determinate, which fields return a failure ?

3) on http://www.the-art-of-web.com/html/html5-form-validation/ I found nice summary about HTML5 validations. Will this be supported in HtmlForms somehow, especially the "required" tag ?

Thx
WOlfgang

  2. Re: validation: which field fail ?   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2012-01-11 09:01:40 - In reply to message 1 from w. studer
1) You can decide between normal and reduced error marking for each widget by using ->useReducedErrorMarking() on a form. Depending on this settingg each row or only the widget itself gets the standard htmlform_error-css-class (firebug is your friend here, also see the index.php at the bottom) if the validation failed on this field. You can simply style that class and everything should be alright. If you really specifically need to know if a widget is valid, you can call ->isValid() on every formelement.

2) see 1)

3) In a future version maybe, right now, this is HTML4 with (coming) JS on top. But the thought already crossed my mind :D