x
1
2
3
4
5
6
7
8
9
10
<div class="space-y-4">
<label class="label block " for="form_component_preview_test_model_favorite_fruits">Favorite fruits</label>
<select name="form_component_preview_test_model[favorite_fruits]" id="form_component_preview_test_model_favorite_fruits"><option value="">- Select -</option>
<option value="orange">Orange</option>
<option value="banana">Banana</option>
<option value="apple">Apple</option></select>
<p class="form_errors">
⚠️ Favorite fruits can't be blank
</p>
</div>
1
2
3
custom_model = TestModel.new
custom_model.valid?
render(DropdownComponent.new(form: form(model: custom_model), method: :favorite_fruits, collection: self.class.fruit_options, item_value_method: :value, item_label_method: :label))