RE: [PEAR] Quickform: image as submit button?
| From: | Vignesh M P N | Date: | Fri, 15 Dec 2006 20:12:16 +0000 |
| Subject: | RE: [PEAR] Quickform: image as submit button? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26115@lists.php.net to get a copy of this message | ||
I suggest checking which button was clicked before adding the rules
(which in turn needs to be before validate() is called).
--
Justin Patrin
Thanks for your reply.
But all my validations are at the client side, so the page is not even
posted. Hence I can't check which button was clicked.
Thanks
Vignesh.
-----Original Message-----
From: Justin Patrin [mailto:papercrane@gmail.com]
Sent: Thursday, December 14, 2006 4:19 PM
To: Vignesh M P N
Cc: pear-general@lists.php.net
Subject: Re: [PEAR] Quickform: image as submit button?
On 12/14/06, Vignesh M P N <manivig@iit.edu> wrote:
> Hi
>
>
>
> =========
>
> Question 1
>
> =========
>
> I need to use image as submit button in my Quickform, so I assigned the
> "value" attribute as "submit". Please find below the way I define the
image
> element.
>
>
>
> $loginimgargs = array('value' => 'submit', 'id' =>
'loginimg',
>
> 'onmouseover' =>
> 'FP_swapImg(1,0,/*id*/\'loginimg\',/*url*/\'img/button15.gif\')',
>
> 'onmouseout' =>
> 'FP_swapImg(0,0,/*id*/\'loginimg\',/*url*/\'img/button14.gif\')',
>
> 'onmousedown' =>
> 'FP_swapImg(1,0,/*id*/\'loginimg\',/*url*/\'img/button16.gif\')',
>
> 'onmouseup' =>
> 'FP_swapImg(0,0,/*id*/\'loginimg\',/*url*/\'img/button15.gif\')',
>
> 'fp-style' => 'fp-btn: Embossed Capsule 1; fp-font-style: Bold;
> fp-transparent: 1; fp-proportional: 0',
>
> 'fp-title' => 'Log in');
>
> $formAuth->addElement('image', 'loginimg', 'img/button14.gif',
> $loginimgargs);
>
>
>
>
>
> But when I submit the form by clicking the "loginimg",
> isset($_POST['loginimg']) returns false!
>
>
>
> I tried printing all the POST variables of the form and it printed 2
> variables "loginimg_x" and "loginimg_y" whose values are the respective
> coordinates. Now I can simply use "isset($_POST['loginimg_x'])" for the
code
> to work fine, but is it right way to do it or am I doing anything wrong
> here?
>
Try $form->exportValue('loginimg');
>
>
> =========
>
> Question 2
>
> =========
>
> I validate the Quickform using the rules. But I have two submit buttons in
> the form, for example, "Login" and "New account" buttons. In this case,
the
> rules need to validated only when I click "Login" button and the rules
> shouldn't be validated when I click "New account" button. How to achieve
> this?
>
I suggest checking which button was clicked before adding the rules
(which in turn needs to be before validate() is called).
--
Justin Patrin