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

__construct() public method

Constructor.
public __construct ( array $config = [] ) : void
$config array Configuration options.
return void
    public function __construct(array $config = array())
    {
        $self =& $this;
        $defaults = array('base' => array(), 'text' => array(), 'textarea' => array(), 'select' => array('multiple' => false), 'attributes' => array('id' => function ($method, $name, $options) use(&$self) {
            if (in_array($method, array('create', 'end', 'label', 'error'))) {
                return;
            }
            if (!$name || $method === 'hidden' && $name === '_method') {
                return;
            }
            $info = $self->binding($name);
            $model = $info->class;
            $id = Inflector::camelize(Inflector::slug($info->name));
            return $model ? basename(str_replace('\\', '/', $model)) . $id : $id;
        }, 'name' => function ($method, $name, $options) {
            if (!strpos($name, '.')) {
                return $name;
            }
            $name = explode('.', $name);
            $first = array_shift($name);
            return $first . '[' . join('][', $name) . ']';
        }), 'binding' => function ($object, $name = null) {
            $result = compact('name') + array('data' => null, 'errors' => null, 'class' => null);
            if (is_object($object)) {
                $result = compact('name') + array('data' => $object->data($name), 'errors' => $object->errors($name), 'class' => $object->model());
            }
            return (object) $result;
        });
        parent::__construct(Set::merge($defaults, $config));
    }