getElement() public method

Get an element object of the form by name.
public getElement ( string $elementName ) : Element
$elementName string
return Element
Esempio n. 1
0
 public function testAddElements()
 {
     $e = new Element('text', 'username', 'Username');
     $c = new Checkbox('colors', array('Red', 'Green', 'Blue'));
     $r = new Radio('colors', array('Red', 'Green', 'Blue'));
     $s = new Select('colors', array('Red', 'Green', 'Blue'));
     $t = new Textarea('comments');
     $f = new Form('/submit', 'post');
     $f->addElements($e);
     $f->addElements(array($c, $r, $s, $t));
     $this->assertEquals(5, count($f->getElements()));
     $this->assertInstanceOf('Pop\\Form\\Element', $f->getElement('username'));
     $this->assertTrue($f->isValid());
     $this->assertEquals(0, count($f->getErrors()));
 }