set_select选择所有选项

时间:2015-12-25 21:26:00

标签: codeigniter

为什么set_select制作所有选项selected

$orgOptions = '';
if(!empty($organizations)){
    foreach($organizations as $org){
        $orgOptions .= '<option value="'.$org['id'].'" %sel-org>'.$org['name'].'</option>';
    }
}

$depFormTemplate ='select name="department[%k][organization]" id="org-%k" class="dropdown">
                   <option value="">Organization Name</option>
                  '.$orgOptions.'
                  </select>'; 


if($this->input->post('department')){
                        foreach($this->input->post('department') as $key => $dep){
                            $search = array('%k', '%department', '%sel-org');
                            $replace = array(
                                            $key,
                                            set_value('department['.$key.'][department]'),
                                            set_select('department['.$key.'][organization]',$dep['organization'])
                            );
                            echo str_replace($search, $replace, $depFormTemplate);
                        }
                    }

0 个答案:

没有答案