Search code examples
ruby-on-railssimple-form

How to set placeholder text for collection field


I want the placeholder field to say "Click to select" but the default placeholder still shows "Select Some Options"

 <%= f.input :tag_ids, as: :select, collection: Tag.order(:name), label_method: :name, input_html: {multiple: true}, label: "Select Category:", placeholder: "Click to select", required: true %>

Solution

  • You can use the prompt option, check simple-form's doc example

    f.input :age, collection: 18..60, prompt: "Select your age", selected: 21
    

    https://github.com/plataformatec/simple_form#collections

    You don't need to set as: :select, select is the default value when you render a collection.