public function __construct(array $attributes) { $this->setAttributes($attributes); parent::__construct(); // overwrite default value with value from POST array if (!empty($_POST) && isset($_POST[$this->getAttribute('name')])) { $this->setValue($_POST[$this->getAttribute('name')]); } }
public function __construct($attributes) { if (!is_array(attributes)) { $attributes = array('name' => (string) $attributes); } $this->setAttributes($attributes); parent::__construct(); // overwrite value with value from the post array if (!empty($_POST) && isset($_POST[$this->getAttribute('name')])) { $this->setValue($_POST[$this->getAttribute('name')]); } }
/** * Constructor * * @param string option's inner text * @param mixed array of attributes or just the value (as a string) * @return void **/ public function __construct($attributes = array()) { if (!is_array($attributes)) { $attributes = array('label' => $attributes); } if (array_key_exists('label', $attributes)) { $this->setLabel($attributes['label']); unset($attributes['label']); } $this->setAttributes($attributes); parent::__construct(); }
public function __construct($attributes = array(), array $options = array()) { // assume name attribute if (!is_array($attributes)) { $attributes = array('name' => (string) $attributes); } $this->setAttributes($attributes); // setup Options foreach ($options as $value => $option) { if (!$option instanceof Option) { $option = new Option($option); } $this->setChild($option); } parent::__construct(); }