Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function $form->add_error_to_field #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Scorpshn
Copy link
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.

None yet

1 participant