How can I display CakePHP input validation errors in a different spot the default?

Nick Messick picture Nick Messick · Jun 7, 2010 · Viewed 47.1k times · Source

Let's say I have field that looks like this in the view:

<li class="bigfield">
  <?php echo $form->input('phone', array(
      'placeholder' => 'Phone',
      'label' => false,
      'between' => '<br />'
  )); ?>
</li>

If I have a validation rule on this field and validation fails, I see the following HTML:

<li class="bigfield">
  <div class="input text required error">
      <br>
      <input name="data[Appointment][email]" type="text" placeholder="Email" 
             maxlength="45" value="" id="AppointmentEmail" class="form-error">
      <div class="error-message">Please enter a valid email address</div>
  </div>
</li>

I'm like to do something like move the error message div to an entire different part of the page rather then have it inside with the same <li> as the field itself. What would be the most straight forward way of doing this?

Answer

Kishor Kundan picture Kishor Kundan · Feb 23, 2013

Just updating an old post.

The validations errors are automatically passed on to view (as pointed out by @Angel S. Moreno)

$this->validationErrors