/** * Easier arguments order for hidden fields * * @param string $type hidden * @param string $name Field name * @param string $value Its value * @param array $attributes Attributes */ public function __construct($type, $name, $label, $value, $attributes) { parent::__construct($type, $name, $label, $value, $attributes); // Multiple files field if ($this->type == 'files') { $this->multiple(); $this->type = 'file'; $this->name = $this->name . '[]'; } }
/** * Easier arguments order for selects * * @param string $type select or multiselect * @param string $name Field name * @param string $label Field label * @param array $options Its options * @param mixed $selected Selected entry * @param array $attributes Attributes */ public function __construct($type, $name, $label, $options, $selected, $attributes) { if ($options) { $this->options = $options; } if ($selected) { $this->value = $selected; } parent::__construct($type, $name, $label, $selected, $attributes); }
public function __construct($type, $name, $label, $value, $attributes) { parent::__construct($type, $name, $label, $value, $attributes); // Multiple models population if (is_array($this->value)) { foreach ($this->value as $v) { $_value[] = is_object($v) ? $v->__toString() : $v; } $this->value = implode(', ', $_value); } }
/** * Easier arguments order for selects * * @param string $type select or multiselect * @param string $name Field name * @param string $label Field label * @param array $options Its options * @param mixed $selected Selected entry * @param array $attributes Attributes */ public function __construct($type, $name, $label, $options, $selected, $attributes) { if ($options) { $this->options = $options; } if ($selected) { $this->value = $selected; } parent::__construct($type, $name, $label, $selected, $attributes); // Multiple models population if (is_array($this->value)) { $this->fromQuery($this->value); $this->value = $selected ?: null; } }
/** * Easier arguments order for hidden fields * * @param string $type hidden * @param string $name Field name * @param string $value Its value * @param array $attributes Attributes */ public function __construct($type, $name, $value, $attributes) { parent::__construct($type, $name, '', $value, $attributes); }