lithium\template\helper\Form::_defaults PHP Method

_defaults() protected method

Builds the defaults array for a method by name, according to the config.
protected _defaults ( string $method, string $name, string $options ) : array
$method string The name of the method to create defaults for.
$name string The `$name` supplied to the original method.
$options string `$options` from the original method.
return array Defaults array contents.
    protected function _defaults($method, $name, $options)
    {
        $config = $this->_config;
        $params = compact('method', 'name', 'options');
        $tpls = $this->_templateMap;
        return $this->_filter(__METHOD__, $params, function ($self, $params) use($config, $tpls) {
            $method = $params['method'];
            $name = $params['name'];
            $options = $params['options'];
            $methodConfig = isset($config[$method]) ? $config[$method] : array();
            $options += $methodConfig + $config['base'];
            $options = $self->invokeMethod('_generators', array($method, $name, $options));
            $hasValue = (!isset($options['value']) || $options['value'] === null) && $name && ($value = $self->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 = $config['attributes']['name'];
            $name = $generator($method, $name, $options);
            $tplKey = isset($options['template']) ? $options['template'] : $method;
            $template = isset($tpls[$tplKey]) ? $tpls[$tplKey] : $tplKey;
            return array($name, $options, $template);
        });
    }