简体   繁体   中英

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);
?> 

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM