/** * Validates a color value. According to the W3C this field should ALWAYS have a value. * * @param string $value The value to validate. * * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure. */ public function validate(&$value) { $return = parent::validate($value); if ($return !== true) { return $return; } if (!isset($value) || strlen(trim($value)) < 1) { $value = '#000000'; } if (isset($value) && strlen(trim($value)) > 0) { $valid = is::color($value); if ($valid === false) { $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId())); return sprintf('"%s" has an invalid color (ex. #FFFFFF).', $msglbl); } $value = $valid; } return true; }