rails simple_form prevent select adding a blank by default to collection

Anadi Misra

I'm rendering an array of strings using collections in simple-form gem, I've gone through this answer, but the solutions there did not work well.

here's the Tag

<%= f.input :training_modes, collection: get_training_modes, include_blank: false, input_html: { multiple: true } %>

But when I save through this select I get arrays like these

["", "Instructor Led Training", "Webex"]
Rajdeep Singh

You need to pass include_hidden: false option with the select to remove the hidden field

<%= f.input :training_modes, collection: get_training_modes, include_blank: false, include_hidden: false, input_html: { multiple: true } %>

Hope that helps!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

default select option as blank

From Dev

Use constant with collection_select with simple_form

From Dev

By default simple_form - collection_check_boxes displays hidden_field at the end

From Dev

Rails Simple_form and Select2 with tags

From Dev

Ruby on Rails 4 - simple_form multiple select input

From Dev

Is there a way to prevent MongoDB adding plural form to collection names?

From Dev

Rails Collection Select in Form Not Saving HABTM Association

From Dev

simple_form select collection populated by AJAX

From Dev

Grouped collection in simple_form

From Dev

Rails Simple_Form Multiple Select Checkboxes

From Dev

Ruby on Rails - Adding a human security field into the simple_form gem?

From Dev

Rails acts-as-taggable-on with select2 (and simple_form)

From Dev

Adding angular directives to simple_form in rails breaks selected option for collection input

From Dev

How to use select2-rails with acts_as_taggable_on (simple_form)

From Dev

Rails simple_form default input value not showing

From Dev

simple_form display current value on collection_select

From Dev

How to enforce select a value in selection option using simple_form on Rails 3

From Dev

Use constant with collection_select with simple_form

From Dev

ruby, simple_form Rails, collection

From Dev

By default simple_form - collection_check_boxes displays hidden_field at the end

From Dev

Rails Simple_form and Select2 with tags

From Dev

Simple_form (rails) - How can I set default selected option if I have params[:id]

From Dev

Rails Simple_Form Multiple Select Checkboxes

From Dev

select box by simple_form in Rails - save id, not title

From Dev

Format simple_form collection select

From Dev

Ruby on Rails, simple_form - I want to set a hidden field of the simple_form from a html select_tag field

From Dev

Adding custom label on simple_form select and default option

From Dev

Error with simple_form on Rails

From Dev

Collection_select with Simple_form for category selection

Related Related

  1. 1

    default select option as blank

  2. 2

    Use constant with collection_select with simple_form

  3. 3

    By default simple_form - collection_check_boxes displays hidden_field at the end

  4. 4

    Rails Simple_form and Select2 with tags

  5. 5

    Ruby on Rails 4 - simple_form multiple select input

  6. 6

    Is there a way to prevent MongoDB adding plural form to collection names?

  7. 7

    Rails Collection Select in Form Not Saving HABTM Association

  8. 8

    simple_form select collection populated by AJAX

  9. 9

    Grouped collection in simple_form

  10. 10

    Rails Simple_Form Multiple Select Checkboxes

  11. 11

    Ruby on Rails - Adding a human security field into the simple_form gem?

  12. 12

    Rails acts-as-taggable-on with select2 (and simple_form)

  13. 13

    Adding angular directives to simple_form in rails breaks selected option for collection input

  14. 14

    How to use select2-rails with acts_as_taggable_on (simple_form)

  15. 15

    Rails simple_form default input value not showing

  16. 16

    simple_form display current value on collection_select

  17. 17

    How to enforce select a value in selection option using simple_form on Rails 3

  18. 18

    Use constant with collection_select with simple_form

  19. 19

    ruby, simple_form Rails, collection

  20. 20

    By default simple_form - collection_check_boxes displays hidden_field at the end

  21. 21

    Rails Simple_form and Select2 with tags

  22. 22

    Simple_form (rails) - How can I set default selected option if I have params[:id]

  23. 23

    Rails Simple_Form Multiple Select Checkboxes

  24. 24

    select box by simple_form in Rails - save id, not title

  25. 25

    Format simple_form collection select

  26. 26

    Ruby on Rails, simple_form - I want to set a hidden field of the simple_form from a html select_tag field

  27. 27

    Adding custom label on simple_form select and default option

  28. 28

    Error with simple_form on Rails

  29. 29

    Collection_select with Simple_form for category selection

HotTag

Archive