Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple_form: specify id of text field

I've got the simple simple_form below. I'm trying to make the ID of the input field be 'my-id', but the solution below doesn't work (the id is 'comment_body'). How can I specify the id for that input field?

= simple_form_for(@comment) do |f|
    = f.input :body, as: :string, html: {id: "my-id"}
    = f.button :submit

I've also tried

    = f.input :body, as: :string, id: "my-id"

to no avail.

like image 648
bevanb Avatar asked Dec 20 '22 18:12

bevanb


1 Answers

:input_html works, not :html.

 = f.input :body, as: :string, input_html: {id: "my-id"}
like image 144
bevanb Avatar answered Jan 06 '23 19:01

bevanb