I would overide a save() method of a Proposal object and do a parent::save($conn) it only if it's not empty..
On 15 led, 16:44, Palleas <pall...@gmail.com> wrote: > Hi there ! > > I'm working on a simple Quiz plugin for my Symfony project, so I'm > heavily using the Symfony embedding form system to have one big form > to edit my whole quiz : > - Quiz title > - Quiz questions > - For each questions, a list of proposals > > I want to be able to add a question and a proposal when I edit my > quiz, so here is what I do : > abstract class PluginNoeQuizQuestionForm extends > BaseNoeQuizQuestionForm > { > public function configure() > { > parent::configure(); > $this->useFields(array('label', 'multiple')); > > foreach ($this->getObject()->getProposals() as $id => > $proposition) > { > $pForm = new NoeQuizProposalForm($proposition); > $this->embedForm(sprintf('proposal%d', $id), $pForm); > } > > // new proposal > $newProposal = new NoeQuizProposal(); > $newProposal->setQuestion($this->getObject()); > > $pForm = new NoeQuizProposalForm($newProposal); > $pForm->getValidator('value')->setOption('required', false); > $pForm->getValidator('is_valid')->setOption('required', false); > > $this->embedForm('newproposal', $pForm); > } > > } > > As you can see, my "$pForm" does not contain any mandatory fields > because I want the user to be able to add a proposal to one question > only if he wants to. So it works, I don't have any fatal error, but > every time I save my form, I have an empty proposal that is created. > > Can you see where I went wrong and how to fix this ? ;) > > Thanks!
-- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.