无线电输入在Update Laravel上输入选定的值

时间:2017-11-15 10:02:28

标签: php laravel

嗨,我真的需要你的帮助我有这个刀片视图:

 <table class="optionsForm" style="width:100%">
            <?php  $k=1;  $k<=count($matrix_column_answers->where('deleted', 0)); ?>
            <tr>
              <th> 
                </th>    
                @foreach($matrix_column_answers as $matrix_column_answer)  
                  <th>   
                     @if($matrix_column_answer->deleted == 0)
                    <input type="text" name="matrix_column_answer[{{$k}}]" value="{{$matrix_column_answer->text}}" 
                    class="form-control" placeholder="Column  "> 
                        <input type="hidden" name="matrix_column_answer" value="{{$matrix_column_answer->id}}" 
                    class="form-control" placeholder="Column  "> 
                    @endif
                  </th> 

                   <?php $k++;  ?>
                   @endforeach
            </tr>  
             @foreach($matrix_row_answers as $matrix_row_answer)   
             <?php  $r=1;  $r<=count($matrix_row_answers->where('deleted', 0)); ?>
                <tr id="option{{ $r }}"> 

                  <td>
                    <input type="text" name="matrix_row_answer[{{$r}}]" value="{{$matrix_row_answer->text}}"   class="form-control" placeholder="Row {{ $r }} ">
                @if($matrix_row_answer->row_id && $matrix_row_answer->col_id)
                        <td> 
                          <input type="radio" name="col_nr[{{ $r  }}]" 
                                 value="1"    class="col1" checked>
                        </td>
                        <td>
                          <input type="radio" name="col_nr[{{ $r  }}]" 
                                 value="2"    class="col2" checked>
                        </td>
                        <td>
                          <input type="radio" name="col_nr[{{ $r  }}]" 
                                 value="3"    class="col3" checked>
                        </td> 
                        <td>
                          <input type="radio" name="col_nr[{{ $r  }}]" 
                                 value="4"    class="col4" checked>
                        </td>

                @else

                        <td> 
                            <input type="radio" name="col_nr[{{ $r  }}]" 
                                   value="1"    class="col1">
                        </td>
                        <td>
                            <input type="radio" name="col_nr[{{ $r  }}]" 
                                   value="2"    class="col2">
                        </td>
                        <td>
                            <input type="radio" name="col_nr[{{ $r  }}]"  
                                   value="3"    class="col3">
                        </td> 
                        <td>
                            <input type="radio" name="col_nr[{{ $r  }}]" 
                                   value="4"    class="col4">
                        </td>
                @endif

                         {{--  <input type="hidden" name="row_col_nr[{{$r}}]" value="0" class="row_col_nr{{ $r  }}"> --}}
                  </tr>
                  <tr></tr><?php $r++;  ?>
            @endforeach
          </table> 

我从数据库中获取这个值:

#items: array:4 [▼
    0 => {#562 ▼
      +"id": 431
      +"question_id": 1261
      +"text": "something"
      +"row_id": 431
      +"col_id": 975
    }
     1 => {#565 ▼
      +"id": 432
      +"question_id": 1261
      +"text": "smthing"
      +"row_id": 432
      +"col_id": 976
    ..

这个row_id和col_id告诉我在创建时单击了哪个单选按钮,我从这个值中知道我从db中检查收音机按钮,到目前为止我尝试过它不起作用,它检查所有最后一列的单元格不正确.. 有人能给我一点帮助..?

0 个答案:

没有答案