### Offers.php /** * @var \ZGoffers\MainBundle\Entity\OfferParameter * * @ORM\OneToMany(targetEntity="OfferParameter", mappedBy="offer", cascade={"all"}) */ private $parameters;
### OfferParameter.php /** * @var \ZGoffers\MainBundle\Entity\Offer * * @ORM\ManyToOne(targetEntity="Offer", inversedBy="offer", cascade={"all"}) */ private $offer; ### OfferType.php class OfferType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder ->add('advertiser') ->add('name') ->add('url', 'text', array('label' => 'URL')) ->add('externalUrl', 'text', array('label' => 'External URL')) ->add('dailyCap', 'text', array('label' => 'Daily Cap')) ->add('parameters', 'collection', array( 'type' => new OfferParameterType(), 'allow_add' => true, 'allow_delete' => true )) ->add('active', 'choice', array( 'choices' => array(0 => 'Disabled', 1 => 'Enabled') )); } public function getDefaultOptions(array $options) { return array( 'data_class' => 'ZGOffers\MainBundle\Entity\Offer' ); } } ### OfferParameterType.php class OfferParameterType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder ->add('field') ->add('type', 'choice', array( 'choices' => array( '=' => 'EQUALS', '>' => 'IS GREATER THAN', '>=' => 'IS GREATER THAN OR EQUALS', '<' => 'IS LESS THAN', '<=' => 'IS GREATER THAN OR EQUALS' ) )) ->add('value'); } public function getDefaultOptions(array $options) { return array( 'data_class' => 'ZGOffers\MainBundle\Entity \OfferParameter' ); } } ### Form Handling public function process() { if ('POST' == $this->request->getMethod()) { // bind form data $this->form->bindRequest($this->request); // If form is valid if ($this->form->isValid() && ($offer = $this->form- >getData()) instanceof Offer) { foreach ($offer->getParameters() as $parameter) { $parameter->setOffer($offer); // THIS SHOULDNT BE NEEDED } // save offer to the database $this->entityManager->persist($offer); $this->entityManager->flush(); return true; } } return false; } -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to symfony-devs@googlegroups.com To unsubscribe from this group, send email to symfony-devs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en