simple_form:指定文本字段的 id [英] simple_form: specify id of text field
本文介绍了simple_form:指定文本字段的 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的简单 simple_form.我正在尝试将输入字段的 ID 设为my-id",但下面的解决方案不起作用(id 为comment_body").如何为该输入字段指定 ID?
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
我也试过
= f.input :body, as: :string, id: "my-id"
无济于事.
推荐答案
:input_html
有效,而不是 :html
.
= f.input :body, as: :string, input_html: {id: "my-id"}
这篇关于simple_form:指定文本字段的 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文