简体   繁体   English

Rails form_for,具有不带标签的text_field(不使用CSS)

[英]Rails form_for, having a text_field without a label (without using CSS)

I know this is easy enough just removing the f.label, but then it changes the positioning (ie, would have to add padding). 我知道这很容易,只需删除f.label,但是它会更改位置(即,必须添加填充)。

Is there a way to do this without styling? 有没有办法做到这一点而无需样式?

I tried 我试过了

f.label :example, ""

But that would still yield 'Example' 但这仍然会产生“示例”

Any input is appreciated. 任何输入表示赞赏。

It certainly is a BAD PRACTICE to do what you are asking. 当然,按照您的要求去做是不好的做法。

What I would do is, 我会做的是

  1. Use headers ( <th></th> ) for the labels as the first row (<tr></tr>) in html and the remaining text_fields as subsequent rows. 将标头( <th></th> )用作html中的第一行(<tr></tr>) ,并将其余的text_fields用作后续行。
  2. Im sure that some kind of loop is generating that form, take out the label_tag from the loop and keep only the text_filed_tags inside the loop. 我确定某种形式的循环正在生成该表单,将其从循环中取出,并仅将text_filed_tags保留在循环中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM