<?php
class Application_Form_Example8 extends Twitter_Bootstrap3_Form_Vertical
{
protected $_renderElementsStateIcons = false;
public function init()
{
$this->addElement('text', 'inputSuccess1', [
'label' => 'Input with success',
]);
$this->addElement('text', 'inputWarning1', [
'label' => 'Input with warning',
]);
$this->addElement('text', 'inputError1', [
'label' => 'Input with error',
'required' => true,
]);
$this->addElement('checkbox', 'checkboxSuccess', [
'label' => 'Checkbox with success',
]);
$this->addElement('checkbox', 'checkboxWarning', [
'label' => 'Checkbox with warning',
]);
$this->addElement('checkbox', 'checkboxError', [
'label' => 'Checkbox with error',
'required' => true,
'uncheckedValue' => null,
]);
$this->addElement('submit', 'submit', [
'description' => 'Submit this form to display the status',
]);
}
public function isValid($data)
{
$valid = parent::isValid($data);
// Additional validation elements for warnings
$inputWarning1 = $this->getElement('inputWarning1');
if ( ! $inputWarning1->hasErrors()) {
$inputWarning1
->setAttrib('warning', ['Warning message'])
->setAttrib('success', null);
}
$checkboxWarning = $this->getElement('checkboxWarning');
if ( ! $checkboxWarning->hasErrors()) {
$checkboxWarning
->setAttrib('warning', ['Warning message'])
->setAttrib('success', null);
}
return $valid;
}
}