0
我form.blade.php
就像Laravel形模型
<div class="form-group">
{!! Form::label('title', 'title :', ['class' => 'awesome']) !!}
{!! Form::text('product[title]', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('description', 'description : ', ['class' => 'awesome']) !!}
{!! Form::text('product[description]', null, ['class' => 'form-control']) !!}
<div id="phone" class="form-group">
{!! Form::label('reference_id1', 'reference_id1 : ', ['class' => 'awesome']) !!}
{!! Form::text('product[reference_id1]', null, ['class' => 'form- control']) !!}
</div>
<div class="form-group">
{!! Form::label('category_id', 'category_id : ', ['class' => 'awesome']) !!}
{!! Form::select('category[]', $categories,null, ['class' => 'form- control', 'multiple']) !!}
</div>
<div class="form-group">
{!! Form::label('color', 'color : ', ['class' => 'awesome']) !!}
{!! Form::text('feature[0][color]', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('height', 'height : ', ['class' => 'awesome']) !!}
{!! Form::text('feature[0][height]', null, ['class' => 'form-control']) !!}
</div> `
和我Edit.blade.php
某事象
{!! Form::model($product,['method' => 'PATCH', 'action' => ['[email protected]',$product->id]]) !!}
@include('products.form', ['submitBtn' => 'submit'])
{!! Form::close() !!}
public function edit($id)
{
$product = Product::with('feature')->findOrFail($id);
$categories = Category::pluck('title','id');
return view('products.edit')->withProduct($product)->withCategories($categories);
}
這是當我想編輯產品時,輸入請求被設置爲空! 例如,當我去http://myLarave/Public/product/2/edit的title
和其他投入是空的:( 什麼建議?
我用 路線:: resource('product','ProductController',[ 'names'=> ['index'=>'products_path', 'show'=>'product_path', 'create'=>'create_product_path', 'edit'=>'edit_path'], ]); 在我的web.php文件中(路徑文件) – Omid
你可以嘗試只使用空值''''或'null'來初始化'$ id',並且如果'$ id'不爲'null'或爲空則進行所有操作。 –
其實我的'$ id'不是空的,非常感謝您檢查id – Omid