Skip to content

Add function $form->add_error_to_field#19

Open
Scorpshn wants to merge 1 commit into
stefangabos:masterfrom
Scorpshn:master
Open

Add function $form->add_error_to_field#19
Scorpshn wants to merge 1 commit into
stefangabos:masterfrom
Scorpshn:master

Conversation

@Scorpshn
Copy link
Copy Markdown
Contributor

@Scorpshn Scorpshn commented May 8, 2015

Link error message to a spesific field same as clientside validation
$form = new Zebra_Form('my_form');
$obj = $form->add('text', 'my_text');
if ($form->validate()) {
if ((int)$_POST['my_text']) < 1 || (int)$_POST['my_text']) > 10) {
$form->add_error_to_field('my_text', 'Value must be an integer between 1 and 10!');
}
}
$form->render();

 *  @param  string  $field_id       The Unique name to identify the control where to attach the error block
 *  
 *  @param  string  $error_message  The error message to append to the error block.
 *
 */

Link error message to a spesific field same as clientside validation
$form = new Zebra_Form('my_form');
$obj = $form->add('text', 'my_text');
if ($form->validate()) {
         if ((int)$_POST['my_text']) < 1 || (int)$_POST['my_text']) > 10) {
              $form->add_error_to_field('my_text', 'Value must be an integer between 1 and 10!');
         } 
$form->render();
 
     *  @param  string  $field_id       The Unique name to identify the control where to attach the error block
     *  
     *  @param  string  $error_message  The error message to append to the error block.
     *
     */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant