I have multi forms in one page each form related to question angle and has its own submit button, each question angle have 4 questions so the user can select one question for the question angle using radio buttons. I need to bind the data to the related field using Form data binding , all the other data is binding perfectly but the problem on the radio button .
Controller
$criteria_questions = ['criteria_id' => $criteriaId, 'sector_id' => $sector_id];
$questions = CustomizeQuestion::where($criteria_questions)->get();
$question_angles = $criteria->question_angle()->get();
/* check existing data */
$check_data = ['organisation_id' => $organisation_id, 'customize_criteria_id' => $criteriaId];
$exist_data = RatingDatum::where($check_data)->get();
View:
@foreach($question_angles as $index=>$angle)
<div class="plan bg-plan">
<h5>{{$angle->question_angle}}</h5>
<hr>
@foreach($exist_data as $datum)
@if($datum->question_angle_id == $angle->id)
{!! Form::model($datum,['method' => 'PATCH','action'=>['RatingDataController@update'],$datum->id]) !!}
@endif
@endforeach
@foreach($questions as $question)
@if($question->question_angle_id == $angle->id)
<div class="radio">
<label>
{{var_dump($datum->customize_question_id)}}
{!! Form::radio('customize_question_id['.$index.']', $question->id, $datum->customize_question_id != null ? 'true' : 'false')!!}
{{$question->score}} {{$question->question}}
</label>
</div>
@endif
@endforeach
<div class="form-group">
{!! Form::label('comment','Comment :') !!}
{!! Form::textarea('comment' ,null,['class'=>'form-control', 'rows' => 4]) !!}
{!! Form::label('reference','Reference:') !!}
{!! Form::textarea('reference',null,['class'=>'form-control', 'rows' => 1]) !!}
</div>
{!! Form::submit('Submit Data', ['class' => 'btn btn-success submit']) !!}
{!! Form::close() !!}
<!--/.Plan -->
</div>
dd($exist_data)
0 => RatingDatum {#458 ▶}
1 => RatingDatum {#457 ▼
#table: "ratingdata"
#fillable: array:10 [▶]
+timestamps: true
#connection: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
#attributes: array:15 [▼
"id" => 2
"organisation_id" => 8
"sector_id" => 1
"country_id" => 1
"dimension_id" => 12
"question_angle_id" => 2
"customize_criteria_id" => 33
"customize_question_id" => 7651
"question_weight" => 40
"actual_score" => 30
"value" => "The company has deployed significant measures to promote voluntary community initiatives, that include: "
"comment" => "test"
"reference" => "test"
"created_at" => "2015-12-21 11:28:38"
"updated_at" => "2015-12-21 12:22:25"
]
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1O5URgm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire