/** * Set Child Element * * @param mixed child element (object) or text node (string) * @param string Whether to position the new child before or after existing children * @return object Returns the current element (object) to allow method chaining **/ public function setChild($element, $position = 'bottom') { // you can't nest non-Option if (!$element instanceof Option) { throw new InvalidArgumentException('You cannot set anything other than Option as the child of Select.'); } parent::setChild($element, $position); // overwrite default value with value from POST array if (!empty($_POST) && isset($_POST[$this->getAttribute('name')])) { $this->setValue($_POST[$this->getAttribute('name')]); } return $this; }