Exemplo n.º 1
0
    $t->fail('mergeForm() disallows merging already bound forms');
} catch (LogicException $e) {
    $t->pass('mergeForm() disallows merging already bound forms');
}
$errorSchema = $f1->getErrorSchema();
$t->ok(array_key_exists('d', $errorSchema->getErrors()), 'mergeForm() merges errors after having been bound');
$f1 = new TestForm1();
$f1->getWidgetSchema()->moveField('a', 'last');
// is moved field well positioned when accessed with iterator interface? (#5551)
foreach ($f1 as $f1name => $f1field) {
    $t->is($f1name, 'b', 'iterating on form takes in account ->moveField() operations.');
    break;
}
$f2 = new TestForm2();
$f2->mergeForm($f1);
$t->is_deeply(array_keys($f2->getWidgetSchema()->getFields()), array('c', 'd', 'b', 'a'), 'mergeForm() merges fields in the correct order');
$f1 = new NumericFieldsForm(array('5' => 'default1'), array('salt' => '1'));
$f2 = new NumericFieldsForm(array('5' => 'default2'), array('salt' => '2'));
$f1->mergeForm($f2);
$t->is_deeply($f1->getDefaults(), array('5' => 'default2'), '->mergeForm() merges numeric defaults');
$t->is_deeply($f1->getWidgetSchema()->getLabels(), array('5' => 'label2'), '->mergeForm() merges numeric labels');
$t->is_deeply($f1->getWidgetSchema()->getHelps(), array('5' => 'help2'), '->mergeForm() merges numeric helps');
// ->getJavaScripts() ->getStylesheets()
$t->diag('->getJavaScripts() ->getStylesheets()');
class MyWidget extends sfWidgetForm
{
    protected function configure($options = array(), $attributes = array())
    {
        $this->addRequiredOption('name');
    }
    public function render($name, $value = null, $attributes = array(), $errors = array())