views:

27

answers:

1

In my view, I have:

$form_prop = 'class="inp_step" id="bedrooms"';
echo form_dropdown( "bedrooms", array( null, 0,1,2,3,4,5,6,7,8,9,10), null, $form_prop );

So how do I stick a

<?php echo $this->validation->set_select('myselect', 'one'); ?>

in there?

+2  A: 

The third parameter to form_dropdown(), which you are declaring as 'null', is where you set the default.

I generally code this as a variable, which either gets populated from a database field, or from the user selected value for the field. In the latter case, you have named the select 'bedrooms', so you would set the default as:

$var = set_value('bedrooms');
echo form_dropdown( "bedrooms", array( null, 0,1,2,3,4,5,6,7,8,9,10), $var, $form_prop );

When setting it from a database field:

$var = $db_rec['bedrooms'];
echo form_dropdown( "bedrooms", array( null, 0,1,2,3,4,5,6,7,8,9,10), $var, $form_prop );
coolgeek