Try writing the part that gives you trouble in plain HTML without Collective. When you get it to work then leave it as it is or convert to Collective. Sometimes it makes things more messy then they should be.
Add class dynamically to checkbox in Laravel Collective
I am working with Laravel Collective Form component. I have a checkbox (bsCheckbox because I am using bootstrap) to which I want to dynamically add a class.
FormServiceProvider.php --> boot() Form::component('bsCheckbox', 'components.form.checkbox', ['name', 'value', 'checked', 'attributes' => [] ]);
In my views/components/form/checkbox.blade.php, I have,
{{ Form::checkbox($name, $value, $checked, array_merge(['class' => 'form-check-input'], $attributes)) }} {{ Form::label( $value, null, array_merge( ['class' => 'form-check-label'], $attributes) ) }}In my show.blade.php, I am using this component in my form element {{ Form::bsCheckbox('completed', $action->title, ($action->completed) ? true : false, ['onChange'=>'this.form.submit()']) }}
Here, I want to add a new class to apply a css class to the LABEL if the action is complete, to indicate that the action is complete (change color or apply a line-through).
If I add the class as an array it gets added to the input component. But I cannot get it to load to the label component.
Appreciate your inputs.
Please or to participate in this conversation.