在简单表单中手动设置表单输入字段的ID? [英] Manually set the ID's of form input fields in a simpleform form?

查看:96
本文介绍了在简单表单中手动设置表单输入字段的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以推翻表单中textfield的simpleform命名?

Is it possible to overrule simpleform's naming of textfields within a form?

此:

= f.input_field :age_from,

输出为:

<input type="text" size="50" name="/people/search[query]" id="_people_search_query">

应该是

<input type="text" size="50" name="/people/search[query]" id="query">

我尝试过 *:name =>查询" *:id =>查询"

I tried * :name => "query" * :id => "query"

无济于事

推荐答案

就像您的其他问题一样,html选项应该以simple_form的形式在input_html哈希中传递:

Like your other question html options should be passed in input_html hash in simple_form:

<%= f.input :age_from, ..., :input_html => { :id => 'my_id' } %> should work.

这篇关于在简单表单中手动设置表单输入字段的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆