Laravel: Form Data Binding – radio buttons

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'=>['[email protected]'],$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" => "2022-12-21 11:28:38"
"updated_at" => "2022-12-21 12:22:25"
]

from Newest questions tagged laravel-5 – Stack Overflow http://ift.tt/1O5URgm
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.