劉信佑
2016-12-01 21:08
ErrorException in Model.php line 2697:Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation (View: /home/ubuntu/workspace/resources/views/student/_form.blade.php) (View: /home/ubuntu/workspace/resources/views/student/_form.blade.php)
@foreach($student->sex() as $ind=>$val)
<label class="radio-inline">
<input type="radio" name="Student[sex]"
{{ isset($student->sex) && $student->sex == $ind ? 'checked' : '' }}
value="{{ $ind }}">{{ $val }}
</label>
@endforeach
修改页面可以使用,但是create加了isset之后仍然报错
将sex()改成别的方法比如sexList()
这个可以通过在model中添加一个默认的属性
public $sex = 0;
我用了isset就没有报错了
<input type="radio" {{isset($student->sex) && $student->sex==$item?'checked="checked"':''}} name="student[sex]" value="{{$item}}"> {{$value}}
轻松学会Laravel-表单篇
32653 学习 · 255 问题
相似问题