I\'m using Bootstrap 3.0RC1
with CakePHP 2.3.6
. Trying to take advantage of those beautiful looking classes like has-error
and has-w
SOLUTION I USE:
Everytime you create a new input, check if there are any errors for that field using CakePhp function isFieldError() and simply append "has-error" class to div just like i did below:
Just div setting:
'div' => array('class' => "form-group ".($this->Form->isFieldError('username') ? 'has-error' : '')),
Full code for one field:
Form->input(
'username',
array(
'label' => array('text' => 'Username', 'class' => 'strong'), 'placeholder' => "Your Username", 'class' => 'form-control',
'div' => array('class' => "form-group ".($this->Form->isFieldError('username') ? 'has-error' : '') ),
'error' => array('attributes' => array('wrap' => 'p', 'class' => 'help-block has-error'))
)
); ?>