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

Reply via email to