diff --git a/lib/widget/base.rb b/lib/widget/base.rb index a58e92b050..2923cc86a0 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -11,26 +11,35 @@ class Widget::Base < Widget end def render_with_options(options = {}, &block) + help_text = options[:help_text] if canvas = options[:to] canvas << "\n" << render(&block) else render(&block) end end - + ## # An optional help text. If defined the Help Widget # displaying the given text is going to be placed # next to this Widget, if it supports that. - def help_text; end - + def help_text + @help_text + end + + def help_text=(text) + @help_text = text + end + ## # Appends the Help Widget with this Widget's help text # if it is defined to the input. # If the help text is not defined the input is returned. def maybe_with_help(html, options = {}) - if help_text - help = render_widget Widget::Controls::Help, help_text do + text = options[:text] + text ||= help_text unless options[:ignore_default] + if text + help = render_widget Widget::Controls::Help, text do options end html + help