lithium\template\helper\Form::_defaults()
Builds the defaults array for a method by name, according to the config.
Parameters
-
string
$method
The name of the method to create defaults for.
-
string
$name
The
$name
supplied to the original method. -
string
$options
$options
from the original method.
Returns
arrayDefaults array contents.
Source
protected function _defaults($method, $name, $options) {
$params = compact('method', 'name', 'options');
return Filters::run($this, __FUNCTION__, $params, function($params) {
$method = $params['method'];
$name = $params['name'];
$options = $params['options'];
$methodConfig = isset($this->_config[$method]) ? $this->_config[$method] : [];
$options += $methodConfig + $this->_config['base'];
$options = $this->_generators($method, $name, $options);
$hasValue = (
(!isset($options['value']) || $options['value'] === null) &&
$name && $value = $this->binding($name)->data
);
$isZero = (isset($value) && ($value === 0 || $value === "0"));
if ($hasValue || $isZero) {
$options['value'] = $value;
}
if (isset($options['value']) && !$isZero) {
$isZero = ($options['value'] === 0 || $options['value'] === "0");
}
if (isset($options['default']) && empty($options['value']) && !$isZero) {
$options['value'] = $options['default'];
}
unset($options['default']);
$generator = $this->_config['attributes']['name'];
$name = $generator($method, $name, $options);
$tplKey = isset($options['template']) ? $options['template'] : $method;
$template = isset($this->_templateMap[$tplKey]) ? $this->_templateMap[$tplKey] : $tplKey;
return [$name, $options, $template];
});
}