protected function validateColorFieldValue()
    {
        $field = 'color';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (!isset($value) || $value === '') {
            return null;
        }

        if (preg_match('/#([a-fA-F0-9]{3}){1,2}\b/', $value) !== 1) {
            $this->setErrorInvalid($field, $this->translation->text('Color'));
            return false;
        }

        // HTML5 color field cannot have empty value
        // Default value is #000000
        // Assuming black is empty
        if ($value === '#000000') {
            $this->setSubmitted($field, '');
        }

        return true;
    }
protected function validateColorFieldValue()
    {
        $field = 'color';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (!isset($value) || $value === '') {
            return null;
        }

        if (preg_match('/#([a-fA-F0-9]{3}){1,2}\b/', $value) !== 1) {
            $this->setErrorInvalid($field, $this->translation->text('Color'));
            return false;
        }

        // HTML5 color field cannot have empty value
        // Default value is #000000
        // Assuming black is empty
        if ($value === '#000000') {
            $this->setSubmitted($field, '');
        }

        return true;
    }
protected function validateColorFieldValue ( ) { $ field = 'color' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) || $ value === '' ) { return null ; } if ( preg_match ( '/#([a-fA-F0-9]{3}){1,2}\b/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Color' ) ) ; return false ; } // HTML5 color field cannot have empty value // Default value is #000000 // Assuming black is empty if ( $ value === '#000000' ) { $ this -> setSubmitted ( $ field , '' ) ; } return true ; }
Validates a color code
@return boolean|null
Validates a color code