Re: [PHP] Submit/Validate triggering problem.

2005-10-22 Thread Richard Lynch
On Fri, October 21, 2005 10:51 am, Uros Dukanac wrote:
> I can make "workaround" by checking the value of $Filter (is it "A" or
> "B") to
> determine which button sent a request (see "Workaround code" after
> "Original
> code"), but it looks "dirty" to me, and I'm wondering why to do that

It's pretty standard to check which button was pressed by what values
are sent from the browser.

That's just how it's done.

>   if ($AForm->validate() && Filter == "A")

I got no clue what all the QuickForm and validate() stuff is doing,
but you may not really care about validate() here unless $Filter ==
'B'...

So I'd maybe switch the order of the tests and put $Filter first.

Or maybe you always want validate() for A to run, even when they don't
click on A?

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Submit/Validate triggering problem.

2005-10-21 Thread Uros Dukanac
Dear anyone... :)

First, I hope I'm sending this message to correct address.
If this is not the case I'm apologizing for wasting your time, and I'm asking 
you to give me the right e-mail address.

=== GENERAL 
LAMP Environment
PEAR - HTML_QuickForm 3.2.4pl1 stable
Platform: SuSE 9.3
=

=== PROBLEM 
I have a following "problem" (don't know is this a bug or not):
I have one HTML page, two FORMS, two TEXT fields and two SUBMIT buttons - A 
and B.
When I click either A or B button to submit a form program enters in both
validate() parts - In A and in B so the result on screen from code below is:

In A Validate In B Validate
==

=== WHAT I WANT ===
I would like to enter in A part when I click on A submit button, and to enter 
in B part when I click on B submit button.
==

=== QUESTION AND FEW MORE INFO ===
I can make "workaround" by checking the value of $Filter (is it "A" or "B") to 
determine which button sent a request (see "Workaround code" after "Original 
code"), but it looks "dirty" to me, and I'm wondering why to do that if I 
already have two different instances of HTML_QuickForm assigned to two 
different variables $AForm and $BForm.
Why element from $BForm triggers $AForm->validate() and vice versa?
==

Thank you in advance.


Below is the code:
=== Original code ==
addElement("Text", "Name1", "Text1", array("size" => "30"));
$AForm->addElement("Submit", "AButton", "A");
if ($AForm->validate())
{
echo " In A Validate ";
}

// Create new instance - Form B
$BForm = new HTML_QuickForm("Form2", "POST");
$BForm->addElement("Text", "Name2", "Text2", array("size" => "30"));
$BForm->addElement("Submit", "BButton", "B");
if ($BForm->validate())
{
echo " In B Validate ";
}

// Display Forms
$AForm->display();
$BForm->display();
?>


=== Workaround code ==
addElement("Text", "Name1", "Text1", array("size" => "30"));
$AForm->addElement("Submit", "SButton", "A");
if ($AForm->validate() && Filter == "A")
{
echo " In A Validate ";
}

// Create new instance - Form B
$BForm = new HTML_QuickForm("Form2", "POST");
$BForm->addElement("Text", "Name2", "Text2", array("size" => "30"));
$BForm->addElement("Submit", "SButton", "B");
if ($BForm->validate() && Filter == "B")
{
echo " In B Validate ";
}

// Display Forms
$AForm->display();
$BForm->display();
?>

-- 
Uros Dukanac
---
LucidTech | Svetogorska 2 | 11000 Beograd
tel: +381 11 3033386 | fax: +381 11 3033391
http: www.lucidtech.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php