No worries, you can of course give your submits a cake like name data[Model][submit] or some such, and it'll come through in your data array. >From there logic could be shifted to your model or some such even. Options are endless.
-----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Arne-Kolja Bachstein Sent: Monday, 10 December 2007 7:59 p.m. To: Cake PHP Subject: Re: One form with two submit buttons Hi websta, thanks, that did the trick. Didnt notice the submit button doesn't need a cake style predefined name, so its been quite obvious I think. But now with your help it works, thanks :-) Bye Arne On Dec 10, 4:21 am, "websta*" <[EMAIL PROTECTED]> wrote: > Pretty straight forward, name your submit buttons (my example uses form > helper format) > > echo $form->create()); > echo $form->input('query'); > echo $form->submit('Submit A',array('name'=>'sa')); > echo $form->submit('Submit B',array('name'=>'sb')); > echo $form->end(); > > then in your controller you can pick up which submit has been hit by > checking the Controller::params['form']. > > Add this in your controller method and you'll get what I mean. > > function my_method(){ > if(!empty($this->data)){ > pr($this->params); > } > > } > > So you can go: > > if(!empty($this->data)){ > if(isset($this->params['form']['sa'])){ > $searchField = 'field_a'; > }elseif(isset($this->params['form']['sb'])){ > $searchField = 'field_b'; > } > > ... do search > > } > > or something similar. > > There of course a many of ways of doing this but that's a start for ya. > > HTH. > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf > > Of Arne-Kolja Bachstein > Sent: Sunday, 9 December 2007 6:24 p.m. > To: Cake PHP > Subject: One form with two submit buttons > > Hi, > > I have to implement a search form like > > <form> > <input type="text" /> > <input type="submit" value="Search for phrase in A" /> > <input type="submit" value="Search for phrase in B" /> > </form> > > How could I do this the cake way, is there any option? I cannot > imagine atm how to do this at all, but maybe someone out there has a > clue... > > Thanks in advance > > Arne > > __________ NOD32 2711 (20071207) Information __________ > > This message was checked by NOD32 antivirus system.http://www.eset.com __________ NOD32 2712 (20071209) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
