2013-05-21 47 views
0

我在寫我的自定義FormBuilder,我不明白爲什麼方法如下自定義問題提交在FormBuilder

def submit(label = "Save changes", *args) 
    options = args.extract_options! 
    new_class = options[:class] || "btn btn-small btn-success" 
    @template.content_tag(:div, :class => "form-actions left") do 
    @template.content_tag(:button, :class => new_class, :name => 'commit', :type => 'submit', :value => label) do 
     @template.content_tag(:i, :class => 'icon-arrow-right icon-on-right') 
    end 
    end 
end 

輸出爲:

<div class="form-actions left"> 
    <button class="btn btn-small btn-success" name="commit" type="submit" value="Salvar"> 
     <i>{:class=&gt;&quot;icon-arrow-right icon-on-right&quot;} 
     </i> 
    </button> 
</div> 

尤其是「我」標籤。我該如何解決它? 謝謝。

回答

1

因此,如果content_tag得到一個塊,塊結果將被用作標記的內容。沒有塊,第二個參數是內容。你可能想要的是

@template.content_tag(:i, nil, :class => 'icon-arrow-right icon-on-right')