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
 }
Beispiel #4
0
 /**
  * Output the control
  */
 public function __toString()
 {
     \bootbuilder\BootBuilder::getForm()->renderControl($this);
 }
            <?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);
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="container">
            <h1>Sample Form</h1>
            <?php 
require __DIR__ . '/../vendor/autoload.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;
$form = BootBuilder::openHorizontal();
$form->setAction("");
$form->setId("sampleform");
$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");
$email = new Email("email", "Your e-mail");
$email->setRequired(true);
$area = new TextArea("sample_area");
$password = new Password("login_password", "Password");
$password->setDisabled(true);
$checkb1 = new Checkbox("remember", "Remember my settings");
$checkb2 = new Checkbox("accept", "Accept our privacy policy");
$checkb2->setChecked(true);
$radio1 = new Radio("envi", "Live version", "envi_live", "live");