PHP Classes

Selected option Bug

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  Locating addresses on...  >  All threads  >  Selected option Bug  >  (Un) Subscribe thread alerts  
Subject:Selected option Bug
Summary:There is a bug in the selected option for non multiple selects
Messages:10
Author:Shoeb
Date:2006-08-17 07:14:02
Update:2006-09-07 07:17:34
 

  1. Selected option Bug   Reply   Report abuse  
Picture of Shoeb Shoeb - 2006-08-17 07:14:02
Hi,

Condition:

$iama = array(
""=>"",// IF THERE IS A EMPTY OPTION THEN THE SELECTED OPTION WHEN DEFINING THE FILED DOSENT WORKS
"mastercard"=>"Master Card",
"visa"=>"Visa",
"amex"=>"American Express",
"dinersclub"=>"Diners Club",
"carteblanche"=>"Carte Blanche",
"discover"=>"Discover",
"enroute"=>"enRoute",
"jcb"=>"JCB"
);

$form->AddInput(array(
"TYPE"=>"select",
"ID"=>"iama",
"NAME"=>"iama",
"LABEL"=>"I am a:",
"VALUE"=>"visa", // THIS IS WHERE I AM STRESSING
"OPTIONS"=>$iama,
));


Regards,
Accilies

  2. Re: Selected option Bug   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-08-18 18:35:15 - In reply to message 1 from Shoeb
Some PHP versions have bugs dealing with arrays. Which PHP version do you use?

  3. Re: Selected option Bug   Reply   Report abuse  
Picture of Shoeb Shoeb - 2006-08-19 05:07:33 - In reply to message 2 from Manuel Lemos
Hi,

PHP Version 5.1.1

Regards,
Accilies

  4. Re: Selected option Bug   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-08-19 06:14:48 - In reply to message 3 from Shoeb
AFAIK, that PHP version is not affected by PHP array bugs.

What exactly it means it does not work?

Are you using that select field to use the class credit card validation? In that case, "" is not a valid credit card type. "unknown" accepts any card with a valid number. "visa" only accepts VISA cards but there may be some cards with newer VISA number ranges that the class is not yet accepting.

If you are trying to validate a VISA card, is it accepted if you choose "unknown" type? How many digits does it have in total? What are the first four digits?

  5. Re: Selected option Bug   Reply   Report abuse  
Picture of Shoeb Shoeb - 2006-08-23 06:11:31 - In reply to message 4 from Manuel Lemos
Hi,

no its not a credit card select option just any select option you see where i have a default selected value either defined or from database for example..

$default = "trader";

$iama = array(
""=>"",// IF THERE IS A EMPTY OPTION THEN THE SELECTED OPTION WHEN DEFINING THE FILED DOSENT WORKS
"trader"=>"trader",
"speaker"=>"speaker",
);

$form->AddInput(array(
"TYPE"=>"select",
"ID"=>"iama",
"NAME"=>"iama",
"LABEL"=>"I am a:",
"VALUE"=>$default, // THIS IS WHERE I AM STRESSING
"OPTIONS"=>$iama,
));

This dosent work at my end.

Regards,
Accilies

  6. Re: Selected option Bug   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-08-23 06:51:14 - In reply to message 5 from Shoeb
That default VALUE must be one of the keys of the OPTIONS associative array.

Does the AddInput call return an error when you experience that problem?

  7. Re: Selected option Bug   Reply   Report abuse  
Picture of chris lejeune chris lejeune - 2006-09-06 15:49:19 - In reply to message 6 from Manuel Lemos
Hi Manuel,

I would like to Not select an option--then "ValidateAsNotEmpty--forcing my customer to make a choice. If I select an option as the default, I'm picking the option for him. From what I can tell, the class does not allow for not selecting an option.

For now, I created a dummy element in the assoc array called: "Select One", but I'm going to have to catch it outside the class.

Is there a better way to do this inside the class?

Thank You,

chris

  8. Re: Selected option Bug   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-09-06 17:50:06 - In reply to message 7 from chris lejeune
Single select inputs must have one option selected. Even if the class generated a select input without one option selected, the browser sets it to the first option value.

ValidateAsNotEmpty may work in cases where an empty string would not be a valid option.

If an empty string can be a valid option, you should use ValidateAsDifferentFromText parameters to add the input and set it to a value that you are sure it is not a valid option value.

  9. Re: Selected option Bug   Reply   Report abuse  
Picture of chris lejeune chris lejeune - 2006-09-06 19:13:37 - In reply to message 8 from Manuel Lemos
Bravo! Great suggestion! "ValidateAsDifferentFrom" is the answer. Thank you Manuel for getting back to me so quickly!

  10. Re: Selected option Bug   Reply   Report abuse  
Picture of Shoeb Shoeb - 2006-09-07 07:17:35 - In reply to message 6 from Manuel Lemos
Hi Manuel,

Sorry but i was not intimated abt your reply. I guess I need to take a closer look to explan the bug (if in case i was not mistaken)

- Accilies