Esempio n. 1
0
 /**
  * Embeds a sfForm into the current form.
  *
  * @param string $name       The field name
  * @param sfForm $form       A sfForm instance
  * @param string $decorator  A HTML decorator for the embedded form
  */
 public function embedForm($name, sfForm $form, $decorator = null)
 {
     $name = (string) $name;
     if (true === $this->isBound() || true === $form->isBound()) {
         throw new LogicException('A bound form cannot be embedded');
     }
     unset($form[self::$CSRFFieldName]);
     $this->embeddedForms[$name] = $form;
     $widgetSchema = $form->getWidgetSchema();
     $this->setDefault($name, $form->getDefaults());
     $decorator = null === $decorator ? $widgetSchema->getFormFormatter()->getDecoratorFormat() : $decorator;
     $this->widgetSchema[$name] = new sfWidgetFormSchemaDecorator($widgetSchema, $decorator);
     $this->validatorSchema[$name] = new sfValidatorPass();
     // keep widgetSchema synchronized
     $form->setWidgetSchema($this->widgetSchema[$name]->getWidget());
     $this->resetFormFields();
 }