21301 Posts in 5736 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 149 Views |
-
String value instead of index from the Dropdownfield

7 August 2012 at 8:31pm
Hey,
I have a form which contains a dropdownfield in the following format: new DropdownField('Reproducibility', 'Reproducibility', array('Always','Sometimes','Randomly','Have not tried'))
When I'm trying to get the string values, it's giving array index instead of string values. How can I retrieve the real values which are shown in the dropdownfield?
Thanks!
-
Re: String value instead of index from the Dropdownfield

7 August 2012 at 11:43pm Last edited: 7 August 2012 11:43pm
The value of the dropdown field is determined by the key in the array you are passing. Since you do not set the keys, they are numeric. Try something like
new DropdownField('Reproducibility', 'Reproducibility',
array('always' => 'Always', 'sometimes'=>'Sometimes', 'randomly'=>'Randomly', 'nottried' => 'Have not tried'));
Avoid spaces in the keys.
| 149 Views | ||
|
Page:
1
|
Go to Top |

