Pop\Form\Form::setErrorDisplay PHP Method

setErrorDisplay() public method

Set error pre-display globally across all form element objects
public setErrorDisplay ( string $container, array $attribs, boolean $pre = false ) : Form
$container string
$attribs array
$pre boolean
return Form
    public function setErrorDisplay($container, array $attribs, $pre = false)
    {
        if (null === $this->errorDisplay) {
            $this->errorDisplay = array('container' => 'div', 'attributes' => array('class' => 'error'), 'pre' => false);
        }
        foreach ($this->form->childNodes as $child) {
            $child->setErrorDisplay($container, $attribs, $pre);
        }
        $this->errorDisplay['container'] = $container;
        $this->errorDisplay['attributes'] = $attribs;
        $this->errorDisplay['pre'] = $pre;
        return $this;
    }

Usage Example

Example #1
0
 public function testConstructorSetFields()
 {
     $fields = array('username' => array('type' => 'text', 'value' => 'Username here...', 'label' => 'Username:'******'required' => true, 'attributes' => array('size' => 40)));
     $f = new Form('/submit', 'post', $fields);
     $f->setErrorDisplay('h3', array('class' => 'error-class'), true);
     $this->assertEquals(1, count($f->getFields()));
 }