public static function validationMessage($propertyName, $validationMessage = null, $tag = 'span', $htmlAttributes = array()) {
        $propertyName = (is_array($propertyName) ? implode('_', $propertyName) : $propertyName);
        $htmlAttributes = ($htmlAttributes === null ? array() : $htmlAttributes);
        $tag = empty($tag) ? 'div' : trim($tag, '<>');

        if (!isset($htmlAttributes['class'])) {
            $htmlAttributes['class'] = 'field-validation-error';
        }
        else {
            $htmlAttributes['class'] .= ' field-validation-error';
        }

        if (!empty($errors = self::$viewContext->getModelState()->getErrors($propertyName))) {
            $result = '<' . $tag . ' ' . self::buildAttributes($htmlAttributes) . '>';
            
            if (!empty($validationMessage)) {
                $result .= htmlspecialchars($validationMessage) . '<br />';
            }

            $result .= implode('<br />', array_map('htmlspecialchars', $errors));

            $result .= '</' . $tag . '>';

            return $result;
        }
    }
public static function validationMessage($propertyName, $validationMessage = null, $tag = 'span', $htmlAttributes = array()) {
        $propertyName = (is_array($propertyName) ? implode('_', $propertyName) : $propertyName);
        $htmlAttributes = ($htmlAttributes === null ? array() : $htmlAttributes);
        $tag = empty($tag) ? 'div' : trim($tag, '<>');

        if (!isset($htmlAttributes['class'])) {
            $htmlAttributes['class'] = 'field-validation-error';
        }
        else {
            $htmlAttributes['class'] .= ' field-validation-error';
        }

        if (!empty($errors = self::$viewContext->getModelState()->getErrors($propertyName))) {
            $result = '<' . $tag . ' ' . self::buildAttributes($htmlAttributes) . '>';
            
            if (!empty($validationMessage)) {
                $result .= htmlspecialchars($validationMessage) . '<br />';
            }

            $result .= implode('<br />', array_map('htmlspecialchars', $errors));

            $result .= '</' . $tag . '>';

            return $result;
        }
    }
public static function validationMessage ( $ propertyName , $ validationMessage = null , $ tag = 'span' , $ htmlAttributes = array ( ) ) { $ propertyName = ( is_array ( $ propertyName ) ? implode ( '_' , $ propertyName ) : $ propertyName ) ; $ htmlAttributes = ( $ htmlAttributes === null ? array ( ) : $ htmlAttributes ) ; $ tag = empty ( $ tag ) ? 'div' : trim ( $ tag , '<>' ) ; if ( ! isset ( $ htmlAttributes [ 'class' ] ) ) { $ htmlAttributes [ 'class' ] = 'field-validation-error' ; } else { $ htmlAttributes [ 'class' ] .= ' field-validation-error' ; } if ( ! empty ( $ errors = self :: $ viewContext -> getModelState ( ) -> getErrors ( $ propertyName ) ) ) { $ result = '<' . $ tag . ' ' . self :: buildAttributes ( $ htmlAttributes ) . '>' ; if ( ! empty ( $ validationMessage ) ) { $ result .= htmlspecialchars ( $ validationMessage ) . '<br />' ; } $ result .= implode ( '<br />' , array_map ( 'htmlspecialchars' , $ errors ) ) ; $ result .= '</' . $ tag . '>' ; return $ result ; } }
Gets a validation message if an error exists for the specified field.

@param string|array $propertyName The name of the property that is being validated.
It can be a string or an array.
If an array is specified, the property chain in the model will be searched.
For example: array('A', 'B') is $model->A->B.
@param string $validationMessage The message to display if the field contains an error.
@param string $tag The tag to wrap the message in the generated HTML. Default: span.
@param array $htmlAttributes The HTML attributes for the element.

@return string
Gets a validation message if an error exists for the specified field .