KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing a form which is dealing with multiple models. Some examples of how to do this use ActionView::Helpers::FormHelper::label , and some use ActionView::Helpers::FormTagHelper::label_tag , and I don't really understand the difference. In my particular case, both seem to result in the same output: <% form_for :post, :url => { :action => 'create' } do %> <p> <%= label_tag 'post_type' %><br /> <%= text_field :post, :post_type %> </p> <p> <%= label :post, :parent_post_id %><br /> <%= text_field :post, :parent_post_id %> </p> ... Renders: <p> <label for="post_type">Post type</label><br /> <input id="post_post_type" name="post[post_type]" size="30" type="text" /> </p> <p> <label for="post_parent_post_id">Parent post</label><br /> <input id="post_parent_post_id" name="post[parent_post_id]" size="30" type="text" /> </p> The label helper would seem to be more useful, because presumably there are some extra things it can do because it knows the model and property it's labelling, but I can't find anything to back that up. Is there a practical difference between the two? When should I use one helper instead of the other?
Tags (comma-separated)
Save Edits
Cancel