我是 ror 新手。如何为输入提供必需的属性[而不是 ruby 提供的必需标签]。当我写这篇文章时,
= form.text_field :title, {html:{required: "required"}}
浏览器显示此内容,
< input html="{:required=>"required"}" id="key_date_title"
name="key_date[title]" size="30" type="text">
最佳答案
如果你看text_field helper
。它需要 3 个参数:object_name、method 和 options = {}。 您可以直接在选项参数中传入任何标准 HTML 属性。
= form.text_field :title, required: true
关于ruby-on-rails - html 无法在 haml/ror form_for 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31043795/