Ok, thanks for your response.
I watch for EventSubscriber because I want to manage the post_bind case.
But if I bind my event subscriber to formBuilder I cannot take other
service. This is the reason because I want to use eventListener: I can
create a service that has services I want (ie Monolog).
Have you any idea how I can do that?
Il giorno mercoledì 10 ottobre 2012 23:05:47 UTC+2, Christophe Coevoet ha
scritto:
> Le 10/10/2012 10:52, Shark a �crit :
> > I'm trying to create a service that is dispatcher after form bind.
> > In service definition I've write:
> > <tag name="kernel.event_listener" event="form.post_bind"
> > method="onFormBind" />
> > But this event was never dispatched. I'm not sure that the name is
> > kernel.event_listener.
> > Can you help me?
> > And later, how can I obtain the form in this service? I must specify
> > it as an argument of the service?
> > Thanks.
> Forms are not using the global event dispatcher, so you cannot register
> listeners with tags. You need to register the listener on the
> FormBuilder. If you want to attach the listener to all forms, you can
> use a type extension to do it. An example can be found here:
> https://github.com/symfony/Form/blob/master/Extension/HttpFoundation/...
> Btw, the fact that the global dispatcher is not used can be understood
> easily when you know that a form in Symfony2 is a hierarchical
> structure: each Form object contains a collection of children, which are
> also Form objects. If they were all using the same dispatcher, it would
> become totally unusable as all Form objects would share the same set of
> listeners
> --
> Christophe | Stof