Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Create a service with form's events
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Shark  
View profile  
 More options Oct 10 2012, 4:52 am
From: Shark <shark...@gmail.com>
Date: Wed, 10 Oct 2012 01:52:55 -0700 (PDT)
Local: Wed, Oct 10 2012 4:52 am
Subject: Create a service with form's events

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe COEVOET  
View profile  
 More options Oct 10 2012, 5:05 pm
From: Christophe COEVOET <s...@notk.org>
Date: Wed, 10 Oct 2012 23:05:40 +0200
Local: Wed, Oct 10 2012 5:05 pm
Subject: Re: [Symfony2] Create a service with form's events
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shark  
View profile  
 More options Oct 11 2012, 5:07 am
From: Shark <shark...@gmail.com>
Date: Thu, 11 Oct 2012 02:07:53 -0700 (PDT)
Local: Thurs, Oct 11 2012 5:07 am
Subject: Re: [Symfony2] Create a service with form's events

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shark  
View profile  
 More options Oct 12 2012, 5:43 am
From: Shark <shark...@gmail.com>
Date: Fri, 12 Oct 2012 02:43:06 -0700 (PDT)
Local: Fri, Oct 12 2012 5:43 am
Subject: Re: Create a service with form's events

I'm just watching
here: http://symfony.com/doc/current/reference/dic_tags.html#kernel-event-s...
I've create my custom service that tags kernel.event_subscriber.
The class was load because if I remove the
"implements EventSubscriberInterface" I get an error.
But, though I've implemented getSubscribedEvents, my function is never
invoked.
There is a solution?

Il giorno mercoledì 10 ottobre 2012 10:52:55 UTC+2, Shark ha scritto:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »