|
<?php |
|
$action = $this->params->action; |
|
|
|
if ($this->params->admin) { |
|
$action = str_replace('admin_', '', $action); |
|
} |
|
|
|
if ($action == 'index') { |
|
$options = array('class' => 'current'); |
|
} else { |
|
$options = null; |
|
} |
|
|
|
$this->Html->addCrumb( |
|
Inflector::humanize($this->params->controller), |
|
array('controller' => $this->params->controller, 'action' => 'index'), |
|
$options |
|
); |
|
|
|
if ($action !== 'index') { |
|
$this->Html->addCrumb( |
|
Inflector::humanize($action), |
|
array('action' => $action, 'admin' => (bool)$this->params->admin), |
|
array('class' => 'current') |
|
); |
|
} |
|
|
|
echo $this->Html->getCrumbs('', array( |
|
'text' => '<i class="icon-home"></i> Home', |
|
'url' => array('action' => '/'), |
|
'class' => 'tip-bottom', |
|
'escape' => false |
|
)); |
|
?> |
|
|
|
public function input($fieldName, $options = array()) { |
|
$options = array_merge($this->__generateValidationAttr($fieldName), $options); |
|
return parent::input($fieldName, $options); |
|
} |
|
|
|
|
|
private function __generateValidationAttr($fieldName) |
|
{ |
|
$validationAttr = array(); |
|
if ($this->model()) { |
|
$modelObj = $this->_getModel($this->model()); |
|
if ($modelObj) { |
|
foreach ($modelObj->validator() as $validateField => $validateProperties) { |
|
if ($validateField == $fieldName) { |
|
foreach ($validateProperties->getRules() as $key => $value) { |
|
if (is_array($value->rule)) { |
|
$validationAttr['data-rule-'.implode('-', $value->rule)] = true; |
|
$validationAttr['data-message-'.implode('-', $value->rule)] = $value->message; |
|
} else { |
|
$validationAttr['data-rule-'.$value->rule] = true; |
|
$validationAttr['data-message-'.$value->rule] = $value->message; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $validationAttr; |
|
} |