[TYPO3-project-formidable] How to have 2 submit btn with 2 different actions ?

Jerome Schneider j.schneider at ameos.com
Mon Jun 25 15:37:41 CEST 2007


Hi jeremy,

Formidable offers the concept of "server event" for this kind of task
Define your two buttons, and on the <onclick> event on each button, add 
a userobj in the events

like this:

<renderlet:BUTTON name="mybtnone" label="Submit one">
   <onclick runat="server" submit="full">
     <userobj>
       <php><![CDATA[

        echo "I'm executing action for click on first btn";

       ]]></php>
     </userobj>
   </onclick>
</renderlet:BUTTON>


<renderlet:BUTTON name="mybtntwo" label="Submit two">
   <onclick runat="server" submit="full">
     <userobj>
       <php><![CDATA[

        echo "I'm executing action for click on second btn";

       ]]></php>
     </userobj>
   </onclick>
</renderlet:BUTTON>


And if you need to know *outside* of the userobj wich button has been 
clicked, you can use, assuming that $oForm contains your formidable object :

if($oForm->aORenderlets["mybtnone"]->_hasThrown("onclick")) {
   // btn one has been clicked
} elseif($oForm->aORenderlets["mybtntwo"]->_hasThrown("onclick")) {
   // btn two has been clicked
} else {
   // no one of these two buttons has been clicked
}


Hope this helps,
Jerome

Jérémy Lecour a écrit :
> Hi,
> I'd like to have a form with 2 different submit buttons, each one making a
> different action.
> 
> What would be the best way to do this ?
> 
> I've tried to put 2 submit renderlets, each one with it's own name. I've
> even tried to add a <data><value> in the renderlet, but when I submit, the
> getFormData() gives axactly the same data, without any reference to the
> submit button.
> 


More information about the TYPO3-project-formidable mailing list