PHP Classes

Problem using SELECT-inputs with MULTIPLE

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  >  Upcoming Visual HTML ...  >  All threads  >  Problem using SELECT-inputs with...  >  (Un) Subscribe thread alerts  
Subject:Problem using SELECT-inputs with...
Summary:An error occurs while setting the MULTIPLE-flag
Messages:4
Author:Tarak Blah
Date:2007-02-28 16:15:30
Update:2007-02-28 22:21:16
 

  1. Problem using SELECT-inputs with...   Reply   Report abuse  
Picture of Tarak Blah Tarak Blah - 2007-02-28 16:15:30
Hello,

when I use a SELECT-input and flag its MULTIPLE-option with "(int) 1" or "true" or "1", I get the following error message:

Nationality: it was not specified a valid input

Here's the AddInputPart for the input-field:

$form->AddInput(array(
"ACCESSKEY" => $_inputs['Nationality']['AccessKey'],
"CLASS" => "InputSelect",
"ID" => "Nationality",
"LABEL" => $_inputs['Nationality']['Label'],
"MULTIPLE" => 1,
"NAME" => "Nationality",
"OPTIONS"=> $countries,
"SIZE" => $_inputs['Nationality']['Size'],
"TABINDEX" => $_inputs['Nationality']['TabIndex'],
"TYPE" => "select",
"VALUE" => "pick",
"ValidateAsDifferentFromText" => "pick",
"ValidateAsDifferentFromTextErrorMessage" => $_inputs['Nationality']['ValidateAsDifferentFromTextErrorMessage']
));

Here's the $_inputs['Nationality']-array:


$_inputs['Nationality'] = array(
"AccessKey" => "N",
"Help" => "Please choose a nationality.",
"Label" => "<u>N</u>ationalities",
"Size" => (int) 3,
"TabIndex" => (int) 5,
"ValidateAsDifferentFromTextErrorMessage" => "Please choose your nationalities!"
);

When I set the MULTIPLE-option to "0" or "false", everything works fine... Once again, I'm wondering if the mistake is on my side... Can anyone explain?

By the way, I'm using the tarball "formsgeneration-2007-02-26.tar.gz"...

  2. Re: Problem using SELECT-inputs with...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-02-28 19:40:58 - In reply to message 1 from Tarak Blah
For multiple select fields, the selected values must be an array passed using the SELECTED option, not the VALUE options.

In any case, you can print the return value of the AddInput function call as that should be a self-explanatory error message.

  3. Re: Problem using SELECT-inputs with...   Reply   Report abuse  
Picture of Tarak Blah Tarak Blah - 2007-02-28 21:42:01 - In reply to message 2 from Manuel Lemos
I'm not really understanding what you mean... What I want is a SELECT-input, where one can choose multiple options like i.e.:

<select name="top5" size="5" multiple="multiple">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>
</select>

I just took the code from the test_form.php example (Credit Card) and just added the MULTIPLE-option to accomplish this.

  4. Re: Problem using SELECT-inputs with...   Reply   Report abuse  
Picture of Tarak Blah Tarak Blah - 2007-02-28 22:21:16 - In reply to message 3 from Tarak Blah
Manuel,

I have to apologize... Thinking about your reply, I haved changed it to:

$form->AddInput(array(
"ACCESSKEY" => $_inputs['Nationality']['AccessKey'],
"CLASS" => "InputSelect",
"ID" => "Nationality",
"LABEL" => $_inputs['Nationality']['Label'],
"LabelCLASS" => "Labels",
"LabelID" => "LabelNationality",
"LabelTITLE" => $_inputs['Nationality']['Help'],
"MULTIPLE" => true,
"NAME" => "Nationality",
"OPTIONS"=> $countries,
"SIZE" => $_inputs['Nationality']['Size'],
"TABINDEX" => $_inputs['Nationality']['TabIndex'],
"TITLE" => $_inputs['Nationality']['Help'],
"TYPE" => "select",
"SELECTED" => array("pick"),
"ValidateAsDifferentFromText" => "pick",
"ValidateAsDifferentFromTextErrorMessage" => $_inputs['Nationality']['ValidateAsDifferentFromTextErrorMessage']
));

Now it works! Thank you very much... How do they say, think before you write?

Shame on me,
Tarak