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
I use a custom Helper that is tailored to whatever the CSS framework is. In this case Bootstrap.
'form-control', 'div'=>false, 'error' => array('attributes' => array('wrap' => 'span', 'class' => 'help-block')));
if (isset($options['label'])) {
if (is_array($options['label'])) {
$options['label'] += array('class' => 'control-label');
} else {
$options['label'] = array('text' => $options['label'], 'class' => 'control-label');
}
} else {
$options['label'] = array('class' => 'control-label');
}
$divOptions = array('class' => "form-group has-feedback");
if (isset($options['div'])) {
if (is_array($options['div'])) {
$divOptions += $options['div'];
}
}
$options['div'] = false;
$divText = $this->Form->input($fieldName, $options);
if ($this->Form->isFieldError($fieldName)) {
$divOptions['class'] = "form-group has-error has-feedback";
$divText .= $this->Html->tag('span', null, array('class' => "glyphicon glyphicon-remove form-control-feedback"));
}
return $this->Html->tag('div', $divText, $divOptions);
}
}
?>
Then use this instead of the standard Form
helper
echo $this->UI->textBox('email'));