我想从数据库中获取所选值并将其显示在codeigniter start
函数中,但显示错误。
控制器:
form_dropdown()
查看:
$type = array(
'options' => array(
'section' => 'Section',
'transaction' => 'Transaction',
'document' => 'Document'
),
'attributes' => array(
'class' => 'form-control'
)
);
答案 0 :(得分:1)
请尝试以下代码:
控制器:
$this->data['type'] = array(
'name' => 'type_value',
'attributes' => 'class="form-control"',
'value' => (isset($database_type_value) && trim($database_type_value)) ? $database_type_value: $this->input->post('type_value',TRUE), //$database_type_value - value from database
'options_list' => array(
'section' => 'Section',
'transaction' => 'Transaction',
'document' => 'Document'
),
);
查看:
<?php echo form_dropdown($type['name'],$type['options_list'],$type['value'],$type['attributes']);?>