To redirect back with previous input, it is common to have return redirect()->back()->withInput();. Then, to retrieve the previous value for radio button:
<input name="question1" value="0" type="radio" id="q1-0" />
<label for="q1-0" class="label-margin">0</label>
<input name="question1" value="1" type="radio" id="q1-1" />
<label for="q1-1" class="label-margin">1</label>
<input name="question1" value="2" type="radio" id="q1-2" />
<label for="q1-2" class="label-margin">2</label>
<input name="question1" value="3" type="radio" id="q1-3" />
<label for="q1-3" class="label-margin">3</label>
It works fine except for the one with value 0. When there is no previous input for question 1, old('question1') also return 0, making the choice 0 always chosen when return, where I want to keep all choices not chosen.
Is there a way to leave choice 0 not blank when there is no previous input?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire