HashanChamara / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
0 stars 0 forks source link

unable to assign Select Option Value different from display value #147

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.define the element (Element_Select)
2.Assign array (array ("0" => "Option#1","1"=>"Option#2"). It used to work with 
V1

What is the expected output? What do you see instead?
Expected
<Select>
<option value="0">Option#1</option>
<option value="2">Option#2</option>
</select>

Saw
<Select>
<option value="Option#1">Option#1</option>
<option value="Option#2">Option#2</option>
</select>

What version of the product are you using? On what operating system?
Version 2.2, Windows XP & 7

Please provide any additional information below.

Original issue reported on code.google.com by lokman4...@gmail.com on 18 Jul 2011 at 10:38

GoogleCodeExporter commented 8 years ago
The array you're passing...

array ("0" => "Option#1","1"=>"Option#2")

...is a one dimensional array.  PHP treats it as such b/c it's a loosely typed 
language.  To override this, and force the option values to be 0, 1, etc as 
intended, you can pass the same array like this...

array("0:pfbc" => "Option#1", "1:pfbc" => "Option#2")

This isn't in any formal documentation but is noted on the project's mailing 
list at 
http://groups.google.com/group/php-form-builder-class/browse_thread/thread/40c43
acca74d16ae?hl=en

Please give that a try and let me know if you're still having issues.

Thanks,
Andrew

Original comment by ajporterfield@gmail.com on 19 Jul 2011 at 2:47

GoogleCodeExporter commented 8 years ago
i have the same problem....

i solved starting the array not in 0 but in 1

array ("1" => "Option#1","2"=>"Option#2") 

Original comment by nuno.mr....@gmail.com on 19 Jul 2011 at 10:21

GoogleCodeExporter commented 8 years ago
Hi Andrew,

Thanks for the info and the link too. It does clear up some confusions I have.

Nuno,

Thanks to you too :)

Original comment by lokman4...@gmail.com on 19 Jul 2011 at 11:04