marvinlabs / laravel-html-bootstrap-4

Bootstrap 4 fluent HTML builder
MIT License
42 stars 15 forks source link

Checkbox with array of options generates checkboxes with duplicate id #52

Open wvdongen opened 5 years ago

wvdongen commented 5 years ago

Checkboxes with the name representing an array of options generates checkboxes with the same id

Example from: https://github.com/marvinlabs/laravel-html-bootstrap-4/blob/master/docs/checkbox.md#checkboxes-with-name-representing-an-array-of-options

{{ bs()->checkbox('hobbies[]')->id('hobby_ski')->description('Skiing') }}
{{ bs()->checkbox('hobbies[]')->id('hobby_surf')->description('Surfing') }}
{{ bs()->checkbox('hobbies[]')->id('hobby_dive')->description('Diving') }}

Generated HTML:

<div class="custom-control custom-checkbox" id="hobby_ski">
    <input class="custom-control-input" type="checkbox" name="hobbies[]" value="1" id="hobbies">
    <label class="custom-control-label" for="hobbies">Skiing</label>
</div>
<div class="custom-control custom-checkbox" id="hobby_surf">
    <input class="custom-control-input" type="checkbox" name="hobbies[]" value="1" id="hobbies">
    <label class="custom-control-label" for="hobbies">Surfing</label>
</div>
<div class="custom-control custom-checkbox" id="hobby_dive">
    <input class="custom-control-input" type="checkbox" name="hobbies[]" value="1" id="hobbies">
    <label class="custom-control-label" for="hobbies">Diving</label>
</div>

All ids in of the three checkboxes are "hobbies". The id should be set on the control object, not on the wrapper.