如何使用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');
答
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');