为什么不这样做:
步骤1:创建一个名为
partials
第二步:创建
_form_field.blade.php
<div class="col-sm-6 col-md-6">
<div class="form-group">
<label class="control-label">{{ $labelName }}</label>
<input name="{{ $input['name'] }}" type="{{ $input['type'] }}" class="{{ $input['class'] }}" />
</div>
</div>
现在,您可以使用此文件并将其包含在视图中的任何位置。是这样的:
@extends('your_main_layout_file_here')
@section('content')
<form action="{{ route('yourPostRoute') }}" method="POST">
@csrf
@include('partials._form_field', [
'labelName' => 'Price',
'input' => [
'type' => 'number',
'name' => 'Price',
'class' => 'form-control'
]
])
</form>
@endsection
希望这对你有帮助。