简单形式空白标签

Min*_*ohn 22 ruby forms ruby-on-rails simple-form

所以我使用Simple Form for my Rails App,我需要摆脱简单表单附带的每个输入上的标签.

我试过:<%= f.input:email,class:"login-field",label:""%>将标签留空,但这不起作用.

我对rails很新,有人可以解释一下如何实现这个目标吗?

编辑:我正在尝试实现这种格式:

<input type="password" class="login-field" value="" placeholder="Password" id="login-pass" />
Run Code Online (Sandbox Code Playgroud)

谢谢.

vee*_*vee 60

你尝试过label:false而不是label:"":

<%= f.input :email, class: "login-field", label: false %>
Run Code Online (Sandbox Code Playgroud)

  • 但我仍然希望标签的容器显示出来,内部没有任何文字.我试过`:label =>"&nbsp"`但是&nbsp; 出现! (4认同)

Jos*_*res 18

老问题,但它对我有用,@ Josh M:

<%= f.input :email, class: "login-field", label: '&nbsp;'.html_safe %>
Run Code Online (Sandbox Code Playgroud)

simple_form(3.0.2)


Mik*_*del 6

我认为要走的路label: false
还在于simple_form_for您可以通过defaults: {label: false}禁用此表单中所有字段的标签。