Home » Php » php – Radio button in Label tag in Laravel blade

php – Radio button in Label tag in Laravel blade

Posted by: admin July 12, 2020 Leave a comment

Questions:

How to make this code into blade of laravel

<label class="radio" for="penyakit-0">
    <input name="penyakit" id="penyakit-0" value="Asma" type="radio">
    Asma
</label>

i’ve tried many ways to the radio button can be clicked from its text by using blade syntax, but still don’t get anything right..

This is my blade syntax for that HTML:

<label class="radio" for="penyakit-0">
    {{ Form::radio('penyakit', 'Asma', array('id'=>'penyakit-0')) }} 
</label>
How to&Answers:

Try:

{{ Form::label('penyakit-0', 'Asma') }}
{{ Form::radio('penyakit', 'Asma', false, array('id'=>'penyakit-0')) }}

Edit:

As Phil Gyford pointed out above, this Laravel snippet doesn’t yield a label element with an embedded input element.

Unfortunately (or fortunately) by design design Laravel opted for the alternate construction using for attribute for some reason.