Hey Raphael, That is exactly what I am trying to achieve here. So thanks for your tip, I'll take yours over Gareths' I do wanna shoot a couple of more questions to both of you that is essentially a spin off the existing question.
First of all, Raphael, I noticed you made use of regular HTML tags, I tried
using Symfony submit_Tag and set up a name parameter, such as:
echo submit_tag('Comment'',' ', ' comments' )
but the HTML always renders itself as :
<input type="submit" value="Comment" name="commit"/> WHich is to imply that
the $name parameter of the submit_tag was not interpreted. I am hoping the
format is correct, here is the API link that I referred to:
http://www.symfony-project.org/api/1_2/FormHelper#method_submit_tag
2nd Could you guys shed some light upon $request variable. I see both of you
guys using it, typically I use it always as:
$this->getRequest()->getParameter()....etc...but is there a way to
initialize $request.
Thanks a ton, Happy weekend![?]
On Thu, Oct 14, 2010 at 4:32 AM, Raphael Schumacher <
[email protected]> wrote:
> Provided that I haven't misunderstood your problem, I think that you
> can add multiple submit buttons to one form, and that you can
> differentiate them in the action through their name attributes. So
> there would be no need to have multiple instances of the (same) form.
>
> E.g. in the template for your form, thw two submit button tags look
> like something:
> <input type="submit" value="Do this" name="_dothis" />
> <input type="submit" value="Do that" name="_dothat" />
>
> Then your action can differentiate the chosen submit item as follows:
> if ($request->hasParameter('_dothis')) {
> // do this
> } elseif ($request->hasParameter('_dothat')) {
> // do that
> }
> OF course the detailed flow depends on your exact workflow. E.g. one
> may offer two submit buttons "_doThis" and "_doThisAndThat", i.e. the
> latter to perform something in addition what to happen by the first
> submit. Then the code in the action could be like:
> if ($request->hasParameter('_dothis')) {
> // do this
> if ($request->hasParameter('_doThisAndThat')) {
> // additionally do that
> }
> }
>
> That's how I saw it in the symfony code (namely in the admin
> generator).
>
> Hope that helps, RAPHAEL
>
>
>
> On 13 Okt., 23:32, Parijat Kalia <[email protected]> wrote:
> > tHANKS Gareth!!!
> >
> > On Wed, Oct 13, 2010 at 12:08 AM, Gareth McCumskey <[email protected]
> >wrote:
> >
> >
> >
> > > In each forms class that you define set the name format for each form
> > > differently. For example in a forms configure() method:
> >
> > > $this->widgetSchema->setNameFormat('form1[%s]');
> >
> > > The second form give it a different name format. Then in the action
> that
> > > recieves the post:
> >
> > > if ($request->isMethod('post'))
> > > {
> > > if ($request->hasParameter('form1')) //NOTE: without the [%s] portion
> > > {
> > > $form1 = new Form1();
> > > $form1->bind($request->getParameter('form1'));
> > > //All the other code here to process form1
> > > }
> > > else if ($request->hasParameter('form2'))
> > > {
> > > $form2 = new Form2();
> > > $form2->bind($request->getParameter('form2'));
> > > //All the other code here to process form2
> > > }
> > > }
> >
> > > Hope that helps :)
> >
> > > On Wed, Oct 13, 2010 at 8:37 AM, Parijat Kalia <[email protected]
> >wrote:
> >
> > >> Hi everyone,
> >
> > >> I have a page with a form [?], and this page actually has 2
> operations
> > >> possible in it. So essentially multiple buttons are required, submit
> button
> > >> 1 carries out function 1 of the form, submit button 2 carries out some
> other
> > >> task. So essentially I think the answer is 2 forms, the way I think
> this can
> > >> be made possible is that each button has an onsubmit javascript that
> causes
> > >> form.submit that causes that particular form to be posted. But how do
> I
> > >> retrieve this information in the actions view???? It is easy to tell
> in the
> > >> template what form is being posted. But in the action, I am not sure
> how I
> > >> can go about differentiating.
> >
> > >> Any clues fellow human beings?
> >
> > >> Regards,
> >
> > >> Parijat
> >
> > >> --
> > >> 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 [email protected]
> > >> To unsubscribe from this group, send email to
> > >> [email protected]<symfony-users%[email protected]>
> <symfony-users%2bunsubscr...@goog legroups.com>
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/symfony-users?hl=en
> >
> > > --
> > > Gareth McCumskey
> > >http://garethmccumskey.blogspot.com
> > > twitter: @garethmcc
> >
> > > --
> > > 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 [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<symfony-users%[email protected]>
> <symfony-users%2bunsubscr...@goog legroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/symfony-users?hl=en
> >
> >
> >
> > 328.png
> > < 1 KBAnzeigenHerunterladen
>
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
<<328.png>>
