small medium large xlarge

12 Nov 2009, 21:30
Cosmo Lee (1 post)

On pg 576 appears the code:

<% form_remote_tag(:url => {:action => ‘send_email’}, :update => ‘email_form’) do %> To: <% text_field ‘email’, ‘to’ %>
From: <% text_field ‘email’, ‘from’ %>
Body: <% text_area ‘email’, ‘body’ %>
<%= submit_tag ‘Send Email’ %> <% end %>

I’m confused by the use of a form_remote_tag helper with text_field helpers instead of text_field_tag helpers.

From what I understand from reading, form_remote_tag is to be used for forms which do not wrap model objects. Regular (non- _tag) field helpers are for use with fields associated with model objects. “_tag” field helpers, which are used for non-model fields, should be used with “_tag” forms, which do not wrap objects, right?

So why would text_field be used here instead of text_field_tag?

And in this case, the field helpers are specifically associating with an object (‘email’), using an old style of usage (according to pg 530) by specifically indicating an object. So, what’s going on here? Is there an associated model object or not?

Since this is just a snippet of view code w/o corresponding controller code it is difficult for me to make out the author’s intent. Is he trying to imply that there is no model object - implied by the usage of form_remote_tag. Or is he implying that there is a model object implied by the use of non “_tag” field helpers? Aren’t the two types, “_tag” and non-“_tag”, exclusive of each other?

Thanks for any help!

You must be logged in to comment