【发布时间】:2015-06-09 13:23:12
【问题描述】:
我的项目中有 2 个用于编辑和插入的表单,并且我正在使用表单模型绑定。
在插入过程中,有一个名为code 的必填字段。此代码与产品的image 关联。所以我希望我在编辑过程中,code 字段应该变成readOnly?
我如何做到这一点?
插入:
{!! Form::open(['url' => '/admin/products', 'autocomplete' => 'off', 'id' => 'formAddProduct', 'files' => true, 'name' => 'formAddProduct']) !!}
<div class="errors"></div>
@include('admin.products.form', ['submitButtonText' => 'Add Product', 'submitButtonId' => 'btnAddProduct'])
{!! Form::close() !!}
编辑:
{!! Form::model($product, ['method' => 'PATCH', 'action' => ['AdminProductsController@update', $product->id], 'autocomplete' => 'off', 'id' => 'formEditProduct', 'files' => true]) !!}
<div class="errors"></div>
@include('admin.products.form', ['submitButtonText' => 'Edit Product', 'submitButtonId' => 'btnEditProduct'])
{!! Form::close() !!}
form.blade.php:
<div class="form-group">
{!! Form::label('code', 'Code') !!}
{!! Form::text('code', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('category_id', 'Category:') !!}
{!! Form::select('category_id', $categories, null, ['class' => 'form-control']) !!}
</div>
【问题讨论】:
标签: php jquery html laravel laravel-5