Rss Feed

  1. You can get all validation errors from the $this->validationErrors variable on the view. Then feel free to iterate through them and display as you like. They will be organized by model, like so:
    array(
      'User' => array(
        'username' => 'This field cannot be empty.',
        'password' => 'This field cannot be empty.'
      )
    );
    
    Then you can iterate through them on the view and display them as such. This example displays them as an unordered list:
    $errors = '';
    foreach ($this->validationErrors['User'] as $validationError) {
      $errors .= $this->Html->tag('li', $validationError);
    }
    echo $this->Html->tag('ul', $errors);
    
    Lastly, you can hide the form helper's automatic error messages by hiding them with CSS or setting the FormHelper defaults to not show them.
    CSS
    .input.error {
      display: none;
    }
    
    or
    in the view
    $this->Form->inputDefaults(array(
      'error' => false
    ));

  2. 0 comments:

    Post a Comment