Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Form_Decorator_Errors Class Reference

Extends Zend's errors decorator to skip any non-string errors (e.g. More...

List of all members.

Public Member Functions

 render ($content)
 Render errors.

Detailed Description

Extends Zend's errors decorator to skip any non-string errors (e.g.

nested errors). This fixes a problem where Zend's decorator can choke on form errors because they may be two levels deep.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

P4Cms_Form_Decorator_Errors::render ( content)

Render errors.

Parameters:
string$contentThe content to include in errors.
Returns:
string The formatted error output.
    {
        $element = $this->getElement();
        $view    = $element->getView();
        if (null === $view) {
            return $content;
        }

        // remove errors that are not strings.
        $errors = $element->getMessages();
        foreach ($errors as $key => $error) {
            if (!is_string($error)) {
                unset($errors[$key]);
            }
        }

        if (empty($errors)) {
            return $content;
        }

        $separator = $this->getSeparator();
        $placement = $this->getPlacement();
        $errors    = $view->formErrors($errors, $this->getOptions());

        switch ($placement) {
            case self::APPEND:
                return $content . $separator . $errors;
            case self::PREPEND:
                return $errors . $separator . $content;
        }
    }

The documentation for this class was generated from the following file: