I've got a weird problem. I guess more of a semantical one.
Anyways. I have a form in a view to add 2 id-s to DB which connects n questions to n surveys in a table called question_to_survey. I have a value, which I post to another URL, but the Post is empty every time whereas the value given is not (concatenation at the end of the URL).
Controller Store method (I am really novice at web apps):
public function store(Request $request)
{
dd(\Request::input());
$ids = $request->get('ids');
$pieces = explode("_", $ids);
$questionToSurvey = new QuestionToSurvey;
$questionToSurvey->question_id = $pieces[0];
$questionToSurvey->survey_id = $pieces[1];
$questionToSurvey->save();
return redirect('/admin/menu/questions/' . $pieces[0]);
}
The call in the view (I've tested every variable, they all are not null. The value I need in Post is $question->id . "_" . $survey->id). I have used the same form to Post updates to my DB objects in the same project and it works. I am using FormFacade extension. $question is given to the view via compact and I have Models for my DB tables:
@foreach($surveys2 as $survey)
<tr>
<td>{{ $survey->name }}</td>
<td>{{ $survey->id }}</td>
<td>{!! Form::open(['url' => ['admin/menu/questions/add/binding', $question->id . "_" . $survey->id], 'method' => 'POST']) !!}
{!! Form::submit('Add connection', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}</td>
</tr>
@endforeach
The output of post via dd(\Request::input()) (Where is my added argument?):
array:1 [▼
"_token" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
]
The route for it:
Route::post('admin/menu/questions/add/binding/{id}', 'QuestionToSurveyController@store');
Am I missing something? I bet it is something quite easy or I am just breaking somekind of a Laravel convention.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire