Dropdown default value |
[eluser]Ninja[/eluser]
Controller Code: $client = new Client(); View Code: <?php echo form_dropdown('Parent', $parent )?> Im trying to set the default value for the dropdown to something like "Not Applicable" With an index of 0. This dropdown is for Parent clients (ie. The client of a client) but not all clients will have a parent client.
[eluser]steelaz[/eluser]
Assuming "Not Applicable" option index is 0: Code: <?= form_dropdown('Parent', $parent, 0)?> Also... wrong forum, next time try: Code and Application Development
[eluser]davidbehler[/eluser]
If you use the form validation, you could use the set_value function: Code: <?= form_dropdown('Parent', $parent, set_value('Parent', 0))?> That way the default value is 0 but if the form was submitted and did not validate, the selected value will be kept instead of resetting it to 0.
[eluser]Ninja[/eluser]
I have tried both of those options but i think the problem is that "Not Applicable" with index 0 is not in the array and i cant seem to add it to the array.. The array is being populated from the database table clients. which has 3 fields id, parent_client, company_id.
[eluser]Thorpe Obazee[/eluser]
Deja vu http://ellislab.com/forums/viewthread/123388/
|
Welcome Guest, Not a member yet? Register Sign In |