dow5001 2013-08-27 05:20
浏览 31
已采纳

如何使用laravel从数据库创建带有用户名的select,并继续使用Form Class

I would like to insert dynamically because it's from my database and i don't know to do it with the Form class of laravel,

$select = Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S');

is there something like a method to insert data after created ? like

$select->option('far' => 'boo');
  • 写回答

1条回答 默认 最新

  • douqiao3453 2013-08-27 07:44
    关注

    You cannot do that - because Form::select returns a string. i.e. your $select is just a string, not an object

    What you could do is this:

    $select_array = array('L' => 'Large', 'S' => 'Small');
    

    then later on do this dynamically

    $select_array['M'] = 'Medium';
    

    then when you are ready to output the actual display:

    Form::select('size', $select_array, 'S');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部