Skip to content

Commit

Permalink
Break out a setValues method for the Select Element object (out from …
Browse files Browse the repository at this point in the history
…the constructor)
  • Loading branch information
nicksagona committed Sep 24, 2020
1 parent 108799a commit ca38034
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Element/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ public function __construct($name, $values, $selected = null, $xmlFile = null, $
$this->setIndent($indent);
}

$this->setValues($values);
}

/**
* Set the options values of the select form element
*
* @param string|array $values
* @param string $xmlFile
* @param string $indent
* @return Select
*/
public function setValues($values, $xmlFile = null, $indent = null)
{
$values = self::parseValues($values, $xmlFile);

// Create the child option elements.
Expand Down Expand Up @@ -90,6 +103,8 @@ public function __construct($name, $values, $selected = null, $xmlFile = null, $
$this->addChild($option);
}
}

return $this;
}

/**
Expand Down

0 comments on commit ca38034

Please sign in to comment.