PHP Codeigniter: set_value on dropdown menu

前端 未结 6 2222
温柔的废话
温柔的废话 2021-01-05 04:11

I have the following view but how do I apply set_value to it without it defaulting to Please select?

6条回答
  •  囚心锁ツ
    2021-01-05 04:27

    Try this :-

    See url:-- http://codeigniter.com/user_guide/helpers/form_helper.html

    $options = array(
                      'small'  => 'Small Shirt',
                      'med'    => 'Medium Shirt',
                      'large'   => 'Large Shirt',
                      'xlarge' => 'Extra Large Shirt',
                    );
    
    $shirts_on_sale = array('small', 'large');
    
    echo form_dropdown('shirts', $options, 'large');
    

    // Would produce:

    
    
    echo form_dropdown('shirts', $options, $shirts_on_sale);
    

    // Would produce:

    
    

提交回复
热议问题