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