Esempio n. 1
0
    /**
     * Adds a child to the form.
     *
     * @param FormInterface $child The FormInterface to add as a child
     *
     * @return Form the current form
     */
    public function add(FormInterface $child)
    {
        $this->children[$child->getName()] = $child;

        $child->setParent($this);

        if ($this->dataMapper) {
            $this->dataMapper->mapDataToForm($this->getClientData(), $child);
        }

        return $this;
    }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function add(FormInterface $child)
 {
     if ($this->bound) {
         throw new AlreadyBoundException('You cannot add children to a bound form');
     }
     if (!$this->config->getCompound()) {
         throw new FormException('You cannot add children to a simple form. Maybe you should set the option "compound" to true?');
     }
     // Obtain the view data
     $viewData = null;
     // If setData() is currently being called, there is no need to call
     // mapDataToForms() here, as mapDataToForms() is called at the end
     // of setData() anyway. Not doing this check leads to an endless
     // recursion when initializing the form lazily and an event listener
     // (such as ResizeFormListener) adds fields depending on the data:
     //
     //  * setData() is called, the form is not initialized yet
     //  * add() is called by the listener (setData() is not complete, so
     //    the form is still not initialized)
     //  * getViewData() is called
     //  * setData() is called since the form is not initialized yet
     //  * ... endless recursion ...
     if (!$this->lockSetData) {
         $viewData = $this->getViewData();
     }
     $this->children[$child->getName()] = $child;
     $child->setParent($this);
     if (!$this->lockSetData) {
         $this->config->getDataMapper()->mapDataToForms($viewData, array($child));
     }
     return $this;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function add(FormInterface $child)
 {
     if ($this->bound) {
         throw new AlreadyBoundException('You cannot add children to a bound form');
     }
     $this->children[$child->getName()] = $child;
     $child->setParent($this);
     if ($this->config->getDataMapper()) {
         $this->config->getDataMapper()->mapDataToForms($this->getViewData(), array($child));
     }
     return $this;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function add(FormInterface $child)
 {
     if ($this->bound) {
         throw new AlreadyBoundException('You cannot add children to a bound form');
     }
     if (!$this->config->getCompound()) {
         throw new FormException('You cannot add children to a simple form. Maybe you should set the option "compound" to true?');
     }
     $this->children[$child->getName()] = $child;
     $child->setParent($this);
     if ($this->config->getDataMapper()) {
         $this->config->getDataMapper()->mapDataToForms($this->getViewData(), array($child));
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * Adds a child to the form.
  *
  * @param FormInterface $child The FormInterface to add as a child
  *
  * @return Form the current form
  */
 public function add(FormInterface $child)
 {
     if ($this->bound) {
         throw new AlreadyBoundException('You cannot add children to a bound form');
     }
     $this->children[$child->getName()] = $child;
     $child->setParent($this);
     if ($this->dataMapper) {
         $this->dataMapper->mapDataToForm($this->getClientData(), $child);
     }
     return $this;
 }