1. Composer 安装
composer require illuminate/html
需要php-xml扩展支持
2. 添加 providers
修改 config/app.php 文件, 在 providers 数组里面添加:
'IlluminateHtmlHtmlServiceProvider'
3. 添加 aliases
'Form' => 'IlluminateHtmlFormFacade', 'HTML' => 'IlluminateHtmlHtmlFacade'
表单token
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
表单 edit 修改
<form action="/a/{{ $a->id }}" method="post">
<input type="hidden" name="_method" value="put"/>
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
............
</form>
表单错误提示
@if( $errors->any()) <ul class="list-group"> @foreach($errors->all() as $error) <li class="list-group-item list-group-item-danger">{{ $error }}</li> @endforeach </ul> @endif
路由模块绑定 app/Providers/RouteServiceProvider.php
public function boot(Router $router) { // parent::boot($router); $router->model('a','AppArticle'); }
多选框
<select name='tags[]' multiple="multiple"> @foreach($tags as $id => $tag) <option value="{{$id}}">{{ $tag }}</option> @endforeach </select>