Exemplo n.º 1
0
    /**
     * Build the form FieldDescription collection
     *
     * @return void
     */
    protected function buildForm()
    {
        if ($this->form) {
            return;
        }

        // append parent object if any
        // todo : clean the way the Admin class can retrieve set the object
        if ($this->isChild() && $this->getParentAssociationMapping()) {
            $parent = $this->getParent()->getObject($this->request->get($this->getParent()->getIdParameter()));

            $propertyPath = new \Symfony\Component\Form\Util\PropertyPath($this->getParentAssociationMapping());
            $propertyPath->setValue($object, $parent);
        }

        $this->form = $this->getFormBuilder()->getForm();
    }
Exemplo n.º 2
0
 /**
  * Returns a form depend on the given $object
  *
  * @param object $object
  * @param array $options the form options
  * @return \Symfony\Component\Form\Form
  */
 public function getForm($object = null, array $options = array())
 {
     if (!$object) {
         $object = $this->getNewInstance();
     }
     // append parent object if any
     // todo : clean the way the Admin class can retrieve set the object
     if ($this->isChild() && $this->getParentAssociationMapping()) {
         $parent = $this->getParent()->getObject($this->request->get($this->getParent()->getIdParameter()));
         $propertyPath = new \Symfony\Component\Form\Util\PropertyPath($this->getParentAssociationMapping());
         $propertyPath->setValue($object, $parent);
     }
     $formBuilder = $this->getFormBuilder($object, $options);
     return $formBuilder->getForm();
 }