加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – simple_form:指定文本字段的id

发布时间:2020-12-17 03:46:50 所属栏目:百科 来源:网络整理
导读:我在下面有简单的simple_form.我正在尝试将输入字段的ID设为’my-id’,但下面的解决方案不起作用(id为’comment_body’).如何指定该输入字段的ID? = simple_form_for(@comment) do |f| = f.input :body,as: :string,html: {id: "my-id"} = f.button :submit
我在下面有简单的simple_form.我正在尝试将输入字段的ID设为’my-id’,但下面的解决方案不起作用(id为’comment_body’).如何指定该输入字段的ID?

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

我也试过了

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

无济于事.

解决方法

:input_html有效,而不是:html.

= f.input :body,input_html: {id: "my-id"}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读