protected function setUp() { // Prepare session Validator::clean(); // Prepare form $this->form = BootBuilder::open(); $this->form->setId("TestForm"); $this->form->setDisplayErrors(true); $email1 = new Email("email1", "Email Sample"); $email1->setRequired(true); $email2 = new Email("email2", "Email Sample 2"); $email2->setRequired(true); $this->form->add($email1); $this->form->add($email2); }
protected function setUp() { // Prepare session Validator::clean(); // Prepare form $this->form = BootBuilder::open(); $this->form->setId("TestForm"); $this->form->setDisplayErrors(true); $email1 = new Email("email1", "Email Sample"); $email1->setRequired(true); $email2 = new Email("email2", "Email Sample 2"); $email2->setRequired(true); $this->form->add($email1); $this->form->add($email2); $this->form->save(true, false); $validator = new Validator(); $this->validationresult = $validator->load(array("bootbuilder-form" => "TestForm", "email1" => "fakeemail", "email2" => "*****@*****.**"), false)->validate(); $this->loadedForm = $validator->getForm(); }
public function testFormHtml() { $form = BootBuilder::open(); $form->setMethod("test.php"); $form->add(new Text("sample_text")); $boxgroup = new StackPane("Sample checkbox"); $boxgroup->addControl(new Checkbox("sample_unchecked")); $c = new Checkbox("sample_checked"); $c->setChecked(true); $c->setDisabled(true); $boxgroup->addControl($c); $form->add($boxgroup); $html = $form->render(true); $this->assertContains("checkbox", $html); $this->assertContains("<form", $html); $this->assertContains("disabled", $html); $this->assertContains("stackpane", $html); $this->assertContains($c->getId(), $html); // Dynamic id's }
<?php use bootbuilder\BootBuilder; use bootbuilder\Controls\Text, bootbuilder\Controls\TextArea, bootbuilder\Controls\Button, bootbuilder\Controls\Email; use bootbuilder\Controls\Submit, bootbuilder\Controls\Checkbox, bootbuilder\Controls\File, bootbuilder\Controls\Hidden; use bootbuilder\Controls\Password, bootbuilder\Controls\Radio, bootbuilder\Controls\Select, bootbuilder\Controls\CustomHtml; use bootbuilder\Validation\Validator, bootbuilder\Validation\ValidationResult; if (isset($_POST['sample_text'])) { $validator = new Validator(); $validator->load($_POST); $result = $validator->validate(); if ($result->hasError()) { echo "Has error!"; } $form = $validator->getForm(); } else { $form = BootBuilder::open(); $form->setAction(""); $form->setId("sampleform"); $form->setMethod("post"); $form->add(new Text('sample_text', 'Testing Label', null, 'Default Value')); $txt = new Text("sample2"); $txt->setPlaceholder("Placeholder here"); $txt->setLabel("This is a placeholder test"); $txt->setRequired(true); $txt->setHelpText("Enter some text here to test stuff!"); $email = new Email("email", "Your e-mail"); $email->setRequired(true); $email->setHelpText("Valid email required!"); $area = new TextArea("sample_area"); $password = new Password("login_password", "Password"); $password->setDisabled(true);