1

I'm using form tag helper in this way

f.label :something, "label"
f.select :something, options_for_select(...), etc.

But that generate something like this in html

label ....

What I need is that the form tag help prints without the break line

<label></label><select... 

because I need that label select have display:inline-block and that creat inblock spacing gap...

I tried manually creating the label (I'm using haml) where the '>' fix the problem, but I don't know how to create the :for value.

%label{ :for => :something (??)}> 

update

I didn't consider haml as a way to solved my problem, but it looks like in this case may work like this:

f.label :something, "label"
.divwrapper>
    f.select :something, options_for_select(...), etc.

this is a haml hack, I can style the .divwrapper including, keep the form rails form tag helps and with the ">" remove the whitespace around, but still bugging me that Ican't find a way to tell the rails helpers to remove the white space in case that I don't want to use haml for example

raulricardo21
  • 2,499
  • 4
  • 20
  • 27

2 Answers2

2

You can add: %label{ for: "something" } label.

That will be rendered as: <label for="something">label</label>

EDIT

Follow this steps:

  1. Use = f.label :something, 'label'
  2. In the browser using a web inspector see the HTML rendered by 1.
  3. Copy the value: for="value
  4. Use that value in %label{ for: "value" } label
cortex
  • 5,036
  • 3
  • 31
  • 41
  • Hi @Cortex, I see what did there... :) but this is not the solution that I'm loooking for.... But also, I think that I'm start to understand that f is important as a context... I keep looking a bit more information – raulricardo21 Nov 05 '13 at 22:49
0

Would this work for your problem?

f.label :something, "label", class: 'inline-block'

And in your CSS file

inline-block {
  display:inline-block
}
strivedi183
  • 4,749
  • 2
  • 31
  • 38
  • display inline-block is the problem... http://stackoverflow.com/questions/14612980/using-haml-with-the-inline-block-spacing-gaps – raulricardo21 Oct 30 '13 at 23:16
  • Gotcha, ok, my mistake, in that case, `%label{ for: "something"}>` that you suggested should work as long as you remove the symbol :something and replace it with a string 'something' – strivedi183 Oct 30 '13 at 23:38
  • Hi, well, the thing is (and this is my mistake because I pretty in rails) that this :something is really something, because depends on the model. so I can't just put :something, because I need that this symbol to be the same as in f.label :something. You know what I mean – raulricardo21 Oct 31 '13 at 03:16