my controller is like this
$content = View::factory('user/biochemistryTestForm')
->bind('result', $result);
$this->template->content = $content;
//here $result is array of Datatbase records
in view
<?php echo Form::select('allvalues', $result,null, null) ?>
this tag generate code to browser like this
<select name="allvalues">
<option value="0">Photo</option>
<option value="1">Kishore</option>
<option value="2">Chandrapal</option>
<option value="3">Framework</option>
</select>
i want to set values to this tag programatically
help me
I’m not sure if I understand the question fully, but I’ll have a stab at answering regardless.
If you want to set the values of the select options to something other than numeric then you need to assign an array with associative keys to the
$resultvariable in the controller.EDIT: I noticed your
$resultvariable is assigned an array from the database, you’ve not posted the code that assigns a value to$resultso I’m going take a stab in the dark.You need to add
->as_array('key','value')to the end of your Database result call in the controller. The key will be used as the array key, which will become the select option value and the value will be used and the array value which will become the select option label.Controller
Hope this helps.