x
1
2
3
4
5
6
7
8
9
10
11
<div class="space-y-4">
<input value="" autocomplete="off" type="hidden" name="form_component_preview_test_model[favorite_fruits]" id="form_component_preview_test_model_favorite_fruits" />
<input type="hidden" name="form_component_preview_test_model[favorite_fruits][]" value="" autocomplete="off" />
<div class="checkbox_item"><input type="checkbox" value="orange" name="form_component_preview_test_model[favorite_fruits][]" id="form_component_preview_test_model_favorite_fruits_orange" /><label for="form_component_preview_test_model_favorite_fruits_orange">Orange</label></div>
<div class="checkbox_item"><input type="checkbox" value="banana" name="form_component_preview_test_model[favorite_fruits][]" id="form_component_preview_test_model_favorite_fruits_banana" /><label for="form_component_preview_test_model_favorite_fruits_banana">Banana</label></div>
<div class="checkbox_item"><input type="checkbox" value="apple" name="form_component_preview_test_model[favorite_fruits][]" id="form_component_preview_test_model_favorite_fruits_apple" /><label for="form_component_preview_test_model_favorite_fruits_apple">Apple</label></div>
<p class="form_errors">
⚠️ Favorite fruits can't be blank
</p>
</div>
1
2
3
custom_model = TestModel.new
custom_model.valid?
render(CheckboxesComponent.new(form: form(model: custom_model), method: :favorite_fruits, collection: self.class.fruit_options, item_value_method: :value, item_label_method: :label))