/** * Returns a test form * * @return \r8\Form */ public function getTestForm() { $form = new \r8\Form(); $form->setAction("http://www.example.com/submit.php"); $form->andFormValidator(new \r8\Validator\Fail("Form Error")); $form->addField(r8(new \r8\Form\Checkbox("CheckboxFld", "Checkbox Label"))->andValidator(new \r8\Validator\Fail("Checkbox Error"))); $form->addField(new \r8\Form\File("FileFld", "File Label")); $form->addField(r8(new \r8\Form\Hidden("HiddenFld"))); $form->addField(r8(new \r8\Form\Password("PasswordFld", "Password Label"))->andValidator(new \r8\Validator\Fail("Password Error"))); $form->addField(r8(new \r8\Form\Radio("RadioFld", "Radio Label"))->addOption(1234, "Radio Option")->andValidator(new \r8\Validator\Fail("Radio Error"))); $form->addField(r8(new \r8\Form\Select("SelectFld", "Select Label"))->andValidator(new \r8\Validator\Fail("Select Error"))); $form->addField(r8(new \r8\Form\Text("TextFld", "Text Label"))->andValidator(new \r8\Validator\Fail("Text Error"))); $form->addField(r8(new \r8\Form\TextArea("TextAreaFld", "TextArea Label"))->andValidator(new \r8\Validator\Fail("TextArea Error"))); return $form; }
public function testGetTemplateValues() { $form = new \r8\Form(); $form->setAction("http://www.example.com"); $form->setMethod(\r8\Form::METHOD_GET); $form->setEncoding(\r8\Form::ENCODING_URLENCODED); $field1 = new \r8\Form\Text("test1"); $form->addField($field1); $field2 = new \r8\Form\Hidden("test2"); $form->addField($field2); $this->assertEquals(array('form' => $form, 'action' => 'http://www.example.com', 'encoding' => 'application/x-www-form-urlencoded', 'method' => 'GET', 'hidden' => '<input value="" name="test2" type="hidden" />', 'test1' => $field1, 'test2' => $field2), $form->getTemplateValues()); }