【发布时间】:2016-09-27 02:51:21
【问题描述】:
我在 laravel 中有一个表单,可以使用 bootstrap 编辑帖子:
@section('content')
<form method="PUT" action="{{ URL::route('post.update', array($post->id)) }}">
<div class="form-group">
<label for="usr">Title:</label>
<input type="text" class="form-control" id="usr" name="title" value="{{$post->title}}">
<br>
<label for="comment">Details:</label>
<textarea class="form-control" rows="5" id="comment" name="detail"
placeholder="Write a new post.">"{{$post->message}}"</textarea>
<input type="hidden" name="id" value="add">
</div>
<a href="/" class="btn btn-danger" role="button">Cancel</a>
<div class="pull-right">
<input type="submit" class="btn btn-success" value="Update">
</div>
</form>
@stop
现在,如果我使用 Laravel 的 Form 类,它会更小更整洁:
{{Form::model($post, array('method' => 'PUT', 'route' => array('post.update', $post->id)))}}
{{ Form::label('title', 'Post Title: ') }}
{{ Form::text('title') }}
{{ $errors->first('title') }}
<p></p>
{{ Form::label('message', 'Post Message: ') }}
{{ Form::text('message') }}
{{ $errors->first('message') }}
<p></p>
{{ Form::submit('Update') }}
{{ Form::close() }}
但是,这会导致表单看起来很丑:
那么,简而言之,有没有办法使用 Laravel 的表单类并为其添加 boostrap 样式/按钮?我想要具有引导程序视觉效果的表单类的功能和易用性。
【问题讨论】:
-
我迟到了,但我强烈推荐this 包。安装后,您应该可以将
Form替换为BootForm
标签: php forms twitter-bootstrap laravel