laravel-form-builder
laravel-form-builder copied to clipboard
CheckableType sets class attribute to null as default
I've created a form class, added two fields (text and checkbox)
public function buildForm()
{
$this->setFormOption('class', 'form');
$this
->add('name', 'text', [
'rules' => 'required|min:5'
])
->add('publish', 'checkbox');
}
An it generates the following HTML:
<div class="form-group">
<label for="name" class="control-label required">Name</label>
<input class="form-control" required="required" minlength="5" name="name" type="text" id="name"></div>
<div class="form-group">
<input id="publish" name="publish" type="checkbox" value="1">
<label for="publish" class="control-label">Publish</label>
</div>
Text field gets the expected form-control class, but not the checkbox input. I saw in the CheckableType class that this is on purpose, since it sets the type default field class value to null. My question is: why this decision was made? It makes more sense to me that the checkboxes could receive the config field class value. Thanks! :)
Bootstrap 3 doesn't have any classes for the checkboxes, as you can see in this example https://getbootstrap.com/docs/3.3/css/#forms. I see that Bootstrap 4 added some classes for checkboxes, but i still didn't update the defaults to use bootstrap 4 here.