Forum: Ruby on Rails Overridding readonly attribute in custom form builder

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Justin W. (Guest)
on 2007-08-02 23:46
(Received via mailing list)
Hi,

I've created a custom form builder and overridden text_area so that
all fields are readonly.

There are a few instances that I would want an editable text_area, so
I have tried to create an editable_text_area method.



I have tried passing text_area(method,
options.merge(:readonly=>false)) to the method, but it doesn't work:
the area is still not editable.  Any suggestions on how to override
the readonly value in my editable method?

class ReadOnlyFormBuilder < ActionView::Helpers::FormBuilder
  def text_area(method, options = {})
    super(method, options.merge(:readonly=>true))
  end

  def editable_text_area(method, options = {})
    text_area(method, options.merge(:readonly=>false))
  end
end
This topic is locked and can not be replied to.