/** * @param $name * @param $type * @param Form $parent * @param array $options */ public function __construct($name, $type, Form $parent, array $options = []) { $this->name = $name; $this->type = $type; $this->parent = $parent; $this->formHelper = $this->parent->getFormHelper(); $this->setTemplate(); $this->setDefaultOptions($options); $this->setupValue(); }
/** * @param $name * @param $type * @param Form $parent * @param array $options */ public function __construct($name, $type, Form $parent, array $options = []) { $this->name = $name; $this->type = $type; $this->parent = $parent; $this->formHelper = $this->parent->getFormHelper(); $this->setTemplate(); $this->setDefaultOptions($options); $defaultValue = $this->getOption($this->valueProperty); $isChild = $this->getOption('is_child'); if ($defaultValue instanceof \Closure) { $this->valueClosure = $defaultValue; } if ((!$defaultValue || $defaultValue instanceof \Closure) && !$isChild) { $this->setValue($this->getModelValueAttribute($this->parent->getModel(), $name)); } elseif (!$isChild) { $this->hasDefault = true; } }