Example #1
0
 public function testGetDefaultRendererNoneSet()
 {
     $form = new Form('/url');
     $this->assertInstanceOf('Reform\\Form\\Renderer\\BootstrapRenderer', $form->getDefaultRenderer());
 }
Example #2
0
<?php

/*
  Reform examples

  This is all in one file for the sake of example only. Please do not
  write spaghetti code like this!
*/
include '../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Reform\Form\Renderer\BasicRenderer;
use Reform\Form\Form;
use Reform\Validation\Rule;
use Reform\Form\Renderer\FoundationRenderer;
$form = new Form(null);
$form->text('email')->addRule(new Rule\Required())->addRule(new Rule\Email());
$form->number('number')->addRule(new Rule\Range(10, 100));
$form->date('date')->addRule(new Rule\Before(new \DateTime()))->addRule(new Rule\After(new \DateTime('2014-01-01')));
$form->datetime('datetime')->addRule(new Rule\Before(new \DateTime()))->addRule(new Rule\After(new \DateTime('2014-01-01')));
$form->textarea('textarea');
$form->checkbox('checkbox');
$form->hidden('hidden');
$form->password('password')->addRule(new Rule\Required());
$form->select('select')->setChoices(array('Apple' => 'apple', 'Orange' => 'orange', 'Grapes' => 'grapes'));
$form->select('multiple_select')->setChoices(array('Apple' => 'apple', 'Orange' => 'orange', 'Grapes' => 'grapes'))->setMultiple();
$form->submit('submit');
$request = Request::createFromGlobals();
$form->handle($request);
$renderer = isset($_GET['r']) ? $_GET['r'] : 'twbs';
$css = array();
switch ($renderer) {