Merge pull request #2707 from wilr/enums

Tidy up enum matching where classname is missing
This commit is contained in:
Sean Harvey 2013-12-06 15:44:57 -08:00
commit ac1220758e
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 "