newhck / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

Select default value in addselect #59

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Is it possible to select any item as default item in a select other than the 
default item with value="0". I can not find it in the documentation.

What steps will reproduce the problem?
create an array with items to select
addselect to the form

What do you see?
Item with value 0 is selected
<option value="0" selected="selected">

What version of the product are you using? On what operating system?
1.07

Original issue reported on code.google.com by sven.lar...@gmail.com on 2 Jul 2010 at 10:31

GoogleCodeExporter commented 8 years ago
Sven,

I have made some changes in the svn working copy that I believe have corrected 
this issue.  Please test and let me know.  You can get the latest svn working 
copy by running...

svn export http://php-form-builder-class.googlecode.com/svn/trunk/ 
php-form-builder-class

Original comment by ajporterfield@gmail.com on 2 Jul 2010 at 2:17

GoogleCodeExporter commented 8 years ago

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

GoogleCodeExporter commented 8 years ago
It is not working like i would think: 
I made an array like this 

$array[0] = "one";
$array[1] = "two";
$array[2] = "three";

then i add the select and select the item "two" as default. 
$form->addSelect("Select Box:", "field14", "1", $array);

I would also expect the value to be the key of the array and the text showed to 
be the value of it. 

Original comment by sven.lar...@gmail.com on 2 Jul 2010 at 2:51

GoogleCodeExporter commented 8 years ago
Sven,

The array you have provided above is a single dimensional array; therefore, you 
would need to pass "two" as the default value.  If you are passing in a 
two-dimensional array for the options, then you would pass the specific array 
key for the default value.  Does this make sense?

 - Andrew

Original comment by ajporterfield@gmail.com on 2 Jul 2010 at 3:02

GoogleCodeExporter commented 8 years ago
The latest commit, r266, further improves how values of "" and 0 are handled in 
checkbox, radio, select, and checksort elements.   

Original comment by ajporterfield@gmail.com on 2 Jul 2010 at 7:40

GoogleCodeExporter commented 8 years ago

Original comment by ajporterfield@gmail.com on 9 Jul 2010 at 8:03