Beispiel #1
0
$pf->embedForm('ef', $ef);
$pf->bind(array('ef' => array(1 => 'f', 2 => 'potencier')), array('ef' => array('file' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100))));
$t->is($pf->getErrorSchema()->getCode(), 'ef [1 [min_length] file [max_size]]', '->bind() behaves correctly with files in embed form');
// ->renderGlobalErrors()
$t->diag('->renderGlobalErrors()');
$f = new FormTest();
$f->setValidatorSchema(new sfValidatorSchema(array('id' => new sfValidatorInteger(), 'first_name' => new sfValidatorString(array('min_length' => 2)), 'last_name' => new sfValidatorString(array('min_length' => 2)))));
$f->setWidgetSchema(new sfWidgetFormSchema(array('id' => new sfWidgetFormInputHidden(), 'first_name' => new sfWidgetFormInputText(), 'last_name' => new sfWidgetFormInputText())));
$f->bind(array('id' => 'dddd', 'first_name' => 'f', 'last_name' => 'potencier'));
$output = <<<EOF
  <ul class="error_list">
    <li>Id: "dddd" is not an integer.</li>
  </ul>

EOF;
$t->is($f->renderGlobalErrors(), fix_linebreaks($output), '->renderGlobalErrors() renders global errors as an HTML list');
// ->render()
$t->diag('->render()');
$f = new FormTest(array('first_name' => 'Fabien', 'last_name' => 'Potencier'));
$f->setValidators(array('id' => new sfValidatorInteger(), 'first_name' => new sfValidatorString(array('min_length' => 2)), 'last_name' => new sfValidatorString(array('min_length' => 2))));
$f->setWidgets(array('id' => new sfWidgetFormInputHidden(array('default' => 3)), 'first_name' => new sfWidgetFormInputText(array('default' => 'Thomas')), 'last_name' => new sfWidgetFormInputText()));
// unbound
$output = <<<EOF
<tr>
  <th><label for="first_name">First name</label></th>
  <td><input type="text" name="first_name" value="Fabien" id="first_name" /></td>
</tr>
<tr>
  <th><label for="last_name">Last name</label></th>
  <td><input type="text" name="last_name" value="Potencier" id="last_name" /><input type="hidden" name="id" value="3" id="id" /></td>
</tr>
Beispiel #2
0
$pf->embedForm('ef', $ef);
$pf->bind(array('ef' => array(1 => 'f', 2 => 'potencier')), array('ef' => array('file' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100))));
$t->is($pf->getErrorSchema()->getCode(), 'ef [1 [min_length] file [max_size]]', '->bind() behaves correctly with files in embed form');
// ->renderGlobalErrors()
$t->diag('->renderGlobalErrors()');
$f = new FormTest();
$f->setValidatorSchema(new sfValidatorSchema(array('id' => new sfValidatorInteger(), 'first_name' => new sfValidatorString(array('min_length' => 2)), 'last_name' => new sfValidatorString(array('min_length' => 2)))));
$f->setWidgetSchema(new sfWidgetFormSchema(array('id' => new sfWidgetFormInputHidden(), 'first_name' => new sfWidgetFormInput(), 'last_name' => new sfWidgetFormInput())));
$f->bind(array('id' => 'dddd', 'first_name' => 'f', 'last_name' => 'potencier'));
$output = <<<EOF
  <ul class="error_list">
    <li>Id: "dddd" is not an integer.</li>
  </ul>

EOF;
$t->is($f->renderGlobalErrors(), $output, '->renderGlobalErrors() renders global errors as an HTML list');
// ->render()
$t->diag('->render()');
$f = new FormTest(array('first_name' => 'Fabien', 'last_name' => 'Potencier'));
$f->setValidators(array('id' => new sfValidatorInteger(), 'first_name' => new sfValidatorString(array('min_length' => 2)), 'last_name' => new sfValidatorString(array('min_length' => 2))));
$f->setWidgets(array('id' => new sfWidgetFormInputHidden(array('default' => 3)), 'first_name' => new sfWidgetFormInput(array('default' => 'Thomas')), 'last_name' => new sfWidgetFormInput()));
// unbound
$output = <<<EOF
<tr>
  <th><label for="first_name">First name</label></th>
  <td><input type="text" name="first_name" value="Fabien" id="first_name" /></td>
</tr>
<tr>
  <th><label for="last_name">Last name</label></th>
  <td><input type="text" name="last_name" value="Potencier" id="last_name" /><input type="hidden" name="id" value="3" id="id" /></td>
</tr>