Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
根据Laravel 7.24中的数据库值预选单选按钮_Laravel - Fatal编程技术网

根据Laravel 7.24中的数据库值预选单选按钮

根据Laravel 7.24中的数据库值预选单选按钮,laravel,Laravel,我正试图根据数据库中的值预先选择一个单选按钮,到目前为止,其他Stackoverflow答案都不能帮助解决我的问题 问题在于,表单视图中未选择数据库中的值 这是我的密码 刀片 div class="form-group "> <label for="gender">Gender:</label> <br> &nbsp;&nbsp;&nbsp;&nbsp; <input

我正试图根据数据库中的值预先选择一个单选按钮,到目前为止,其他Stackoverflow答案都不能帮助解决我的问题

问题在于,表单视图中未选择数据库中的值

这是我的密码

刀片

div class="form-group ">
 <label for="gender">Gender:</label>
 <br>
 &nbsp;&nbsp;&nbsp;&nbsp;
 <input class="form-check-input" type="radio" name="gender" id="Female" value="Female" {{(old('gender') == Auth::user()->gender) ? 'checked' : '' }}>
 <label class="form-check-label" for="Female">
   Female
 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

 <input class="form-check-input" type="radio" name="gender" id="Male" value="Male" {{ (old('gender') == Auth::user()->gender) ? 'checked' : '' }}>
 <label class="form-check-label" for="Male">
   Male
 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

 <input class="form-check-input " type="radio" name="gender" id="Other" value="Other" {{(old('gender') == Auth::user()->gender) ? 'checked' : '' }}>
 <label class="form-check-label" for="Other">
   Other
 </label>
  </div>
div class=“表单组”>
性别:

性别选中“:”}}> 女性 性别选中“:”}}> 男性 性别选中“:”}}> 其他
检查用户模型,查看是否在可填充数组中添加了
gender
属性。

试试这个

<div class="form-group ">
  <label for="gender">Gender:</label>
  <br>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <input class="form-check-input text-white" type="radio" name="gender" id="Female"  value="Female" {{Auth::user()->gender=="Female" ? 'checked' : '' }} >
  <label class="form-check-label" for="Female">
    Female
  </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

  <input class="form-check-input text-white" type="radio" name="gender"  id="Male"  value="Male" {{Auth::user()->gender=="Male" ? 'checked' : '' }} >
  <label class="form-check-label" for="Male">
    Male
  </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
  <input class="form-check-input text-white" type="radio" name="gender" id="Other"   value="Other" {{Auth::user()->gender=="Other" ? 'checked' : '' }}>
  <label class="form-check-label" for="Other">
    Other
  </label>
   </div>

性别:

性别==“女性”?'选中“:”}}> 女性 性别==“男性”?'选中“:”}}> 男性 性别==“其他”?'选中“:”}}> 其他
关键点更改

div class="form-group ">
 <label for="gender">Gender:</label>
 <br>
 &nbsp;&nbsp;&nbsp;&nbsp;
 <input class="form-check-input" type="radio" name="gender" id="Female" value="Female" {{(old('gender') == Auth::user()->gender) ? 'checked' : '' }}>
 <label class="form-check-label" for="Female">
   Female
 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

 <input class="form-check-input" type="radio" name="gender" id="Male" value="Male" {{ (old('gender') == Auth::user()->gender) ? 'checked' : '' }}>
 <label class="form-check-label" for="Male">
   Male
 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

 <input class="form-check-input " type="radio" name="gender" id="Other" value="Other" {{(old('gender') == Auth::user()->gender) ? 'checked' : '' }}>
 <label class="form-check-label" for="Other">
   Other
 </label>
  </div>
{{Auth::user()->gender==“Female”?“checked”:“}}


将其添加到每个收音机输入字段中。不要忘了将值更改为{==“Male”},等等。

我没有使用Model始终会有一个用户模型。请检查文件User.phpI是否执行了该操作,但没有执行任何操作