Tidy up enum matching where classname is missing

This commit is contained in:
Will Rossiter 2013-12-07 12:18:58 +13:00
parent 6ea59e68ad
commit 20e082d00e
2 changed files with 2 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class Enum extends StringField {
public function __construct($name = null, $enum = NULL, $default = NULL) {
if($enum) {
if(!is_array($enum)) {
$enum = preg_split("/ *, */", trim($enum));
$enum = preg_split("/ *, */", trim(trim($enum, ',')));
}
$this->enum = $enum;

View File

@ -18,7 +18,7 @@ class MultiEnum extends Enum {
// Validate and assign the default
$this->default = null;
if($default) {
$defaults = preg_split('/ *, */',trim($default));
$defaults = preg_split('/ *, */',trim(trim($default, ',')));
foreach($defaults as $thisDefault) {
if(!in_array($thisDefault, $this->enum)) {
user_error("Enum::__construct() The default value '$thisDefault' does not match "