Mani Ratna
Mani Ratna

Reputation: 911

how to load selected data from combo in codeigniter

In codeigniter i want to load my selected data in combo in edit case .How to do so? My code is like this

<?php
$extra=' class="selectCombo"';
$options = array(
    'yes'  => 'Active',
    'no'    => 'Inactive',
);
echo form_dropdown('user_status', $options, set_value('user_status'),$extra);
?> 

Upvotes: 1

Views: 153

Answers (1)

Saty
Saty

Reputation: 22532

set_value Works repopulate the form field with the submitted data not for edit value from database

According to Codeigniter documentation of form_dropdown

The first parameter will contain the name of the field, the second parameter will contain an associative array of options, and the third parameter will contain the value you wish to be selected. You can also pass an array of multiple items through the third parameter, and CodeIgniter will create a multiple select for you.

By passing third parameter your select value

echo form_dropdown('user_status', $options,'yes' ,$extra);

Upvotes: 1

Related Questions