我对Laravel表格有一些疑问。我有一种需要验证的表格,而在表格中只有需要更改的数据。但是问题是我在代码中有一些这样的数据:
<div class="col-sm-8">
<span>{{$trip->country->name}}</span>
</div>
当我单击“保存”按钮时,出现错误,但是更改仍在更新。
试图获取非对象的属性(查看: /mnt/c/Projects/b4g/resources/views/frontend/planner/file.blade.php)
并且由于非对象正在提供{{$trip->country->name}}
,但实际上不应对此进行更新!
我将在此处发布表格: 抱歉,我必须将PHP表单上传到pastebin.com/93kkUg4X
<form id="group-details-update" action="{{action('PlannerController@updateDetails', ['id' => $trip->id])}}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="row form-group {{$errors->has && $errors->has('name') ? 'has-error' : ''}}">
<div class="col-sm-4">
<label class="pull-right">{{untrans('labels.organisation_guest')}}:</label>
</div>
<div class="col-sm-4">
<span class="text-readonly {{$errors->any()?'hidden':''}}">{{$trip->company->name}}</span>
<input class="form-control {{$errors->any()?'':'hidden'}}" name="name" type="text" data-value="{{$trip->company->name}}" value="{{$trip->company->name}}">
@if($errors && $errors->has('name'))
<span class="help-block"><small>{{$errors->first('name')}}</small></span>
@endif
</div>
</div>
<div class="row form-group {{$errors && $errors->has('division') ? 'has-error' : ''}}">
<div class="col-sm-4">
<label class="pull-right">{{untrans('labels.division')}}:</label>
</div>
<div class="col-sm-4">
<span class="text-readonly {{$errors->any()?'hidden':''}}">{{$trip->company->division}}</span>
<input class="form-control {{$errors->any()?'':'hidden'}}" name="division" type="text" data-value="{{$trip->company->division}}" value="{{$trip->company->division}}">
@if($errors && $errors->has('division'))
<span class="help-block"><small>{{$errors->first('division')}}</small></span>
@endif
</div>
</div>
<div class="row form-group {{$errors && $errors->has('street') ? 'has-error' : ''}}">
<div class="col-sm-4">
<label class="pull-right">{{utrans('labels.street_address')}}:</label>
</div>
<div class="col-sm-4">
<span class="text-readonly {{$errors->any()?'hidden':''}}">{{$trip->company->street}}</span>
<input class="form-control {{$errors->any()?'':'hidden'}}" name="street" type="text" data-value="{{$trip->company->street}}" value="{{$trip->company->street}}">
@if($errors && $errors->has('street'))
<span class="help-block"><small>{{$errors->first('street')}}</small></span>
@endif
</div>
</div>
<div class="row form-group {{$errors && $errors->has('zip') ? 'has-error' : ''}}">
<div class="col-sm-4">
<label class="pull-right">{{utrans('labels.zip_code')}}:</label>
</div>
<div class="col-sm-4">
<span class="text-readonly {{$errors->any()?'hidden':''}}">{{$trip->company->zip}}</span>
<input class="form-control {{$errors->any()?'':'hidden'}}" name="zip" type="text" data-value="{{$trip->company->zip}}" value="{{$trip->company->zip}}">
@if($errors && $errors->has('zip'))
<span class="help-block"><small>{{$errors->first('zip')}}</small></span>
@endif
</div>
</div>
<div class="row form-group {{$errors && $errors->has('city') ? 'has-error' : ''}}">
<div class="col-sm-4">
<label class="pull-right">{{utrans('labels.city')}}:</label>
</div>
<div class="col-sm-4">
<span class="text-readonly {{$errors->any()?'hidden':''}}">{{$trip->company->city}}</span>
<input class="form-control {{$errors->any()?'':'hidden'}}" name="city" type="text" data-value="{{$trip->company->city}}" value="{{$trip->company->city}}">
@if($errors && $errors->has('city'))
<span class="help-block"><small>{{$errors->first('city')}}</small></span>
@endif
</div>
</div>
<div class="row">
<div class="col-sm-8 col-sm-offset-4">
<button class="btn btn-primary edit {{$errors->any()?'hidden':''}}" type="button">{{untrans('labels.edit_guest_data')}}</button>
<button class="btn btn-primary save {{$errors->any()?'':'hidden'}}" type="submit">{{utrans('labels.save')}}</button>
<button class="btn btn-primary abort {{$errors->any()?'':'hidden'}}" type="button">{{utrans('labels.abort')}}</button>
</div>
</div>
</form>
答案 0 :(得分:0)
我以您的形式看到
<span class="text-readonly {{$errors->any()?'hidden':''}}">{{$trip->company->name}}</span>
但是你问
$trip->country->name
表单更新company
对象,但不更新country