/** * Test rendering a form with attributes * @depends testRender */ public function testRender_withAttr() { $html = <<<HTML <form method="GET" action="test.php" class="form-horizontal" data-foo="data-foo"> </form> HTML; $this->form->setAttr(array('method' => 'GET', 'action' => 'test.php', 'class' => 'form-horizontal', 'data-foo' => true, 'data-bar' => false)); $this->assertSame($html, (string) $this->form); }
<?php /* This file shows how to use the databse class to select, insert, update and delete data. This file is not designed to be run but to just give an idea of the different ways to use the database. */ /***************** STEP 1 *****************/ // Setup the form (method 1) $form = new Form('#', 'post', array('id' => 'form1', 'name' => 'form1')); // Setup the form (method 1) $form = new Form('#', 'post'); $form->setAttr('id', 'form1'); $form->setAttr('name', 'form1'); /***************** STEP 2 *****************/ // Build form (method 1) $form->name = new FormField('text', 'name', 'Name'); $form->email = new FormField('text', 'email', 'Email Address'); $form->comments = new FormField('textarea', 'comments', 'Comments'); $form->colour = new FormField('select', 'colour', 'Choose a colour', array('multiple' => 'multiple'), array('Red' => 'red', 'Green' => 'green', 'Blue' => 'blue', 'Yellow' => 'yellow'), array('Blue', 'Green')); $form->submit = new FormField('submit', 'submit', false, array('value' => 'Send')); // Build form (method 2) $form->addFields(array('name' => array('text', 'name', 'Name'), 'email' => array('text', 'email', 'Email Address'), 'comments' => array('textarea', 'comments', 'Comments'), 'colour' => array('select', 'colour', 'Choose a colour', array('multiple' => 'multiple'), array('Red' => 'red', 'Green' => 'green', 'Blue' => 'blue', 'Yellow' => 'yellow'), array('Blue', 'Green')), 'submit' => array('submit', 'submit', false, array('value' => 'Send')))); // Build form (method 3) $form->name = new FormField('text', 'name', 'Name'); $form->email = new FormField('text', 'email', 'Email Address'); $form->email->addValidation('required'); $form->email->addValidation('email');