Hi, I don’t know if this has been suggested before (btw is there a
searchable history of the mailing list? - I’m new)
My problem is the following. I have a form with many input fields,
sorted out and cleanly formatted using tables.
I would need to offer users a page exactly like it, only not editable.
And in particular, text areas in the ‘edit’ page will develop scrollbars
and truncate the text if it’s too long, but in the ‘view’ page, I’d like
to show everything.
Of course, the ideal solution would be to use a parameter into the page
(or partial or component) to switch editability on or off. For that,
form helpers should take an “editable” parameter, and produce an input
field or just a value if the parameter is false.
Foe example
<%= text_field "my_class", "compute", {:editable => false} %> |
This would show the actual value, not the
I look at the definition of text_field in
ActionView::Helpers::FormHelper
def text_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self,
nil,options.delete(:object)).to_input_field_tag(“text”, options)
end
Since I prefer not to mess with the rails source, I define my new
function in the helper module for my controller
def text_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self,
nil,options.delete(:object)).value
end
(value is a message defined in the InstanceTag class in module
ActionView::Helpers::FormHelper)
However this doesn’t work at all.
Does someone have any other ideas for achieving edit/view duality
without code duplication?
Is there something already made in Rails?
Thanks
Jaime