// ->setWidgets() ->setWidgetSchema() ->getWidgetSchema() ->getWidget() ->setWidget() $t->diag('->setWidgets() ->setWidgetSchema() ->getWidgetSchema()'); $f = new FormTest(); $widgets = array('first_name' => new sfWidgetFormInputText(), 'last_name' => new sfWidgetFormInputText()); $widgetSchema = new sfWidgetFormSchema($widgets); $f->setWidgetSchema($widgetSchema); $t->ok($f->getWidgetSchema() == $widgetSchema, '->setWidgetSchema() sets the current widget schema'); $f->setWidgets($widgets); $schema = $f->getWidgetSchema(); $widgets['first_name']->setParent($schema); $widgets['last_name']->setParent($schema); $t->ok($schema['first_name'] == $widgets['first_name'], '->setWidgets() sets field widgets'); $t->ok($schema['last_name'] == $widgets['last_name'], '->setWidgets() sets field widgets'); $f->setWidget('name', $w3 = new sfWidgetFormInputText()); $w3->setParent($schema); $t->ok($f->getWidget('name') == $w3, '->setWidget() sets a widget for a field'); // ArrayAccess interface $t->diag('ArrayAccess interface'); $f = new FormTest(); $f->setWidgetSchema(new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText(array('default' => 'Fabien')), 'last_name' => new sfWidgetFormInputText(), 'image' => new sfWidgetFormInputFile()))); $f->setValidatorSchema(new sfValidatorSchema(array('first_name' => new sfValidatorPass(), 'last_name' => new sfValidatorPass(), 'image' => new sfValidatorPass()))); $f->setDefaults(array('image' => 'default.gif')); $f->embedForm('embedded', new sfForm()); $t->ok($f['first_name'] instanceof sfFormField, '"sfForm" implements the ArrayAccess interface'); $t->is($f['first_name']->render(), '<input type="text" name="first_name" value="Fabien" id="first_name" />', '"sfForm" implements the ArrayAccess interface'); try { $f['image'] = 'image'; $t->fail('"sfForm" ArrayAccess implementation does not permit to set a form field'); } catch (LogicException $e) { $t->pass('"sfForm" ArrayAccess implementation does not permit to set a form field'); }