【发布时间】:2016-09-09 09:13:36
【问题描述】:
我正在使用视图来显示我的创建表单,它很长。
在这个表单中,我多次使用相同的代码,主要是带有类名的 div,看起来像这样。
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>**First name:** <span class="text-danger">*</span></label>
{{ Form::text('firstname',null,array('class' =>'form-control required','placeholder' =>'John'))}}
</div>
</div>
</div>
我只想动态更改标签上的 First name: 和 input>
我尝试使用 @yield 和 @section 重用这段代码,但如果它在同一个文件中存在超过 1 次,我会得到与第一个相同的结果。
<!-- First Name -->
@section('form_input_wrapper_label', 'First Name:')
@section('form_input_wrapper_input_area')
{{ Form::text('firstname',null,array('class' =>'form-control required','placeholder' =>'John'))}}
@endsection
@include('theme_components.form_input_wrapper')
<!-- Last Name -->
@section('form_input_wrapper_label', 'Last Name:')
@section('form_input_wrapper_input_area')
{{ Form::text('lastname',null,array('class' =>'form-control required','placeholder' =>'Smith'))}}
@endsection
@include('theme_components.form_input_wrapper')
Laravel 有什么方法可以解决这个问题吗?
【问题讨论】:
标签: php laravel laravel-4 laravel-5