gpt4 book ai didi

html - rails 4 : Change 'name' attribute of Simple Form input

转载 作者:技术小花猫 更新时间:2023-10-29 12:47:00 26 4
gpt4 key购买 nike

我在 Rails 4 应用程序中为 @user 对象使用 Simple Form 并且有一行...

= f.input :entity_name

这会在 input 标签内生成 HTML name='user[entity_name]'。我想更改它,因为我在 Controller 中进行了一些自定义处理,但还没有找到这样做的方法。

我试过将行更改为...

= f.input :entity_name, name: 'entity[name]'

...但这似乎根本不会影响生成的 HTML。到目前为止,我还没有在 Google/Stack Overflow 上发现其他人有这个问题。

有谁知道是否/如何通过简单表单助手更改名称属性?

提前致谢!

最佳答案

诀窍是使用 input_html 选项。

= f.input :entity_name, input_html: { name: 'entity[name]' } 

关于html - rails 4 : Change 'name' attribute of Simple Form input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31226462/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com