Hi Rich, I noticed that there was a problem in the framework preventing what I described.
Could you please add the commits https://github.com/bschussek/symfony/commit/2632186f61651640e8061390b6c8d0adecfb83df and https://github.com/bschussek/symfony/commit/86d1e76430f025caae801deec5277c51fe2de112 to your Symfony2 install and see if they fix your problem? Cheers, Bernhard -- Software Architect & Engineer Blog: http://webmozarts.com Twitter: http://twitter.com/webmozart 2010/12/15 Rich Sage <rich.s...@gmail.com>: > Hi Bernhard, > > Thanks for the below. I'm still hitting an error when submitting the form: > > "Neither element "myBehaviourProperty" nor method "setMyBehaviourProperty()" > exists in class "Application\MyAppBundle\Entity\MyBaseModel" > > as if the "behaviourProperty" field is part of the parent/base model (which > it isn't). This is trying with a basic NotBlank validation (but submitting > a blank value). The subform is appearing as expected on the render, with > field names/IDs as expected. > > Thanks, > > Rich. > > On Wed, Dec 15, 2010 at 10:46 AM, Bernhard Schussek <bschus...@gmail.com> > wrote: >> >> Hi Rich, >> >> You always need a domain model to process the data of the form. What >> you can do though is compose a form of different forms acting on >> different domain models. >> >> I.e. >> >> $form = new Form('base_form', $baseModel); >> $dispatcher->notify('...'); >> >> and in the event handler you can add a subform >> >> $behaviour = new MyBehaviour(); >> $behaviourForm = new Form('my_behaviour', $behaviour); >> $behaviourForm->add(new TextField('behaviourProperty')); >> $form->add($behaviourForm); >> >> class MyBehaviour >> { >> /** constraints defined here */ >> protected $behaviourProperty; >> } >> >> >> Bernhard >> -- >> Software Architect & Engineer >> Blog: http://webmozarts.com >> Twitter: http://twitter.com/webmozart >> >> >> >> 2010/12/15 Rich Sage <rich.s...@gmail.com>: >> > Hi all, >> > >> > I'm experimenting with Symfony2 and the forms framework. I'd like to be >> > able to build a form based on sending events out to various listeners >> > with >> > the form object attached, and have these listeners add fields to the >> > form >> > with validation. Adding fields via event notifications is fine - this >> > is >> > working. I can't see how to add validation to these fields though, as >> > they're not part of a model/Entity class anywhere. As an example, I >> > have a >> > ChoiceField which I need to be able to perform some external validation >> > with >> > the selected value. >> > >> > I've created my Constraint, ConstraintValidator classes, and added a >> > respective validation service into my bundle's XML configuration, but >> > the >> > final step missing is how to apply this validation to the form, >> > presumably >> > at the point of adding the field. This seems to be the crucial step :-) >> > >> > Any pointers? :-) >> > >> > Thanks, >> > >> > Rich >> > >> > -- >> > Rich Sage >> > York, UK >> > rich.s...@gmail.com >> > >> > -- >> > 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 users" group. >> > To post to this group, send email to symfony-users@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 >> > >> >> -- >> 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 users" group. >> To post to this group, send email to symfony-users@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 > > > > -- > Rich Sage > York, UK > rich.s...@gmail.com > > -- > 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 users" group. > To post to this group, send email to symfony-users@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 > -- 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 users" group. To post to this group, send email to symfony-users@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