【问题标题】:Unble to add a class to Laravel form select无法将类添加到 Laravel 表单选择
【发布时间】:2020-06-14 12:34:00
【问题描述】:

我正在使用 Laravel 表单。这是我的代码。

<?php
      $options = $items->pluck('name', 'id')->toArray();
      $options[''] = "Choose...";
?>

{!! Form::select('item_id', $options, array('class' => 'form-control')) !!}
@error('item_id')
     <div class="alert alert-danger">{{ $message }}</div>
@enderror

可惜浏览器不渲染css类,

<select name="item_id">
   ....
</select>

【问题讨论】:

    标签: laravel laravel-form


    【解决方案1】:

    表单的第三个参数是选择的选项,因此您需要将带有类的数组作为第四个参数传递。例如:

    {!! Form::select('item_id', $options, null, array('class' => 'form-control')) !!}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-29
      • 2014-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多