简体   繁体   中英

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).

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.
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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