ruby - Rails: label_tag in helper method not outputting code -
i'm trying write helper method simplify building forms using bootstrap twitter. when try , put label_tag helper method nothing output. every other helper_tag method in function works not label_tag. ideas i'm doing wrong?
name symbol , text labels text
helper code
def bootstrap_form_text_field(name, text) content_tag :div, class: "control-group" label_tag name, text, class: "control-label" content_tag :div, class: "controls" text_field_tag name end end end
view code
<%= bootstrap_form_text_field :called_number, "called number" %>
output
<div class="control-group"><div class="controls"><input id="called_number" name="called_number" type="text" /></div></div>
i'm using ruby-1.9.3-p0 , rails 3.2.2 if helps.
edit: seems last tag helper being called being displayed. copied label_tag below text_field_tag , label thing being displayed.
try this
def bootstrap_form_text_field(name, text) content_tag :div, class: "control-group" label_tag(name, text, class: "control-label") + content_tag(:div, class: "controls") text_field_tag name end end end
i'm not sure if + work correctly that, it's matter of combining results of of tags if have more 1 on each level, combine them in variable , return variable @ end of current scope.
Comments
Post a Comment