Hi Fred,
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.
it’s very confusing for me. But your guess was right. I thought a
symbol is something like a pointer. But that’s not correct it seems
content_tag("div",
content_tag("div", formular.label(method, text) ) + html +
content_tag("div", "", :class => "clear"))
end
okay. I hope I understand.
My original idea was to do something like that I asked for in that
thread
http://groups.google.de/group/rubyonrails-talk/browse_thread/thread/8a9d105037f0e7e0/e9f33293ef733130?lnk=gst&q=%40%40mandatory_fields#e9f33293ef733130
So I tried to break it down to what I thought was essential. So let me
please show you the way I would do it now:
The model Post contains:
class Post < ActiveRecord::Base
@@mandatory = [:title]
validates_presence_of @@mandatory
def self.mandatory
@@mandatory
end
end
My helper:
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 = “”)
if(object.class.mandatory.include?(method))
mandatorytag = “*”
else
mandatorytag = “”
end
content_tag(“div”,
content_tag(“div”, formular.label(method, text) ) + mandatorytag
+
html +
content_tag(“div”, “”, :class => “clear”))
end
I need to pass object again to get the mandatory field(s)
The view
<% form_for(@post) do |f| %>
<%= make_input_row(f, @post, :title, “Titel”)%>
<%= f.submit “Create” %>
<% end %>
Would this be okay?
Thanks for your patience
Martin