Hi Fred,
let form_helper.rb be
module FormHelper
def make_input_row(formular, object, method, text)
make_row(formular, object, method, text,
formular.text_field(method))
end
def make_row(formular, object, method, text, html = "")
content_tag("div",
content_tag("div", label( object, method, text) ) +
html +
content_tag("div", "", :class => "clear"))
end
end
and new.html.erb contain
<% form_for(@post) do |f| %>
<%= make_input_row(f, @post, :title, "Titel")%>
<%= f.submit "Create" %>
<% end %>
Then the output contains
<label for="__Post:0x313f080_title">Titel</label></div><input
id="post_title" name="post[title]" size="30" type="text" />
But if I pass :post it is:
<label for="post_title">Titel</label></div><input id="post_title"
name="post[title]" size="30" type="text" />
So I guess if I pass @post I have to change my make_input_row to
def make_input_row(formular, object, method, text)
make_row(formular, :object, method, text,
formular.text_field(method))
That is entirely useless. :object does not (your later email seems to
indicate your think it does) have any association with the local
variable object.
The reason the object/method things works at all is that by convention
instance variables are uses (and then instance_variable_get comes to
the rescue).
in your particular case, you don't need it at all though
def make_input_row(formular, method, text)
make_row(formular, method, text,formular.text_field(method))
end
def make_row(formular, method, text, html = "")
content_tag("div",
content_tag("div", formular.label(method, text) ) + html +
content_tag("div", "", :class => "clear"))
end
Fred