Re: Quickform: image as submit button?

From: Date: Thu, 14 Dec 2006 22:19:26 +0000
Subject: Re: Quickform: image as submit button?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26099@lists.php.net to get a copy of this message
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

« previous php.pear.general (#26099) next »