Class: AbstractInterface::ThemedFormHelper
- Inherits:
-
Object
- Object
- AbstractInterface::ThemedFormHelper
- Defined in:
- lib/abstract_interface/themed_form_helper.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #error_messages(*errors) ⇒ Object
- #form_field(options, &block) ⇒ Object
-
#initialize(template) ⇒ ThemedFormHelper
constructor
A new instance of ThemedFormHelper.
- #line(*items) ⇒ Object
- #line_with_delimiters(*items) ⇒ Object
Constructor Details
#initialize(template) ⇒ ThemedFormHelper
Returns a new instance of ThemedFormHelper.
5 6 7 |
# File 'lib/abstract_interface/themed_form_helper.rb', line 5 def initialize template self.template = template end |
Instance Attribute Details
#template ⇒ Object
Returns the value of attribute template.
3 4 5 |
# File 'lib/abstract_interface/themed_form_helper.rb', line 3 def template @template end |
Instance Method Details
#error_messages(*errors) ⇒ Object
9 10 11 12 |
# File 'lib/abstract_interface/themed_form_helper.rb', line 9 def *errors errors = errors.first if errors.size == 1 and errors.first.is_a? Array template.render template.themed_partial('forms/errors'), :object => errors end |
#form_field(options, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/abstract_interface/themed_form_helper.rb', line 14 def form_field , &block = .to_openobject = OpenObject.new # prepare options %w(errors label description required theme).each do |k| v = .delete k [k] = v unless v.nil? end .errors = .errors.to_a # CSS style .class ||= "" << " themed_input" .content = template.capture{block.call()} html = template.render(template.themed_partial('forms/field'), :object => ) template.concat html end |
#line(*items) ⇒ Object
35 36 37 |
# File 'lib/abstract_interface/themed_form_helper.rb', line 35 def line *items template.render template.themed_partial('forms/line'), :object => {:items => items, :delimiter => false}.to_openobject end |
#line_with_delimiters(*items) ⇒ Object
39 40 41 |
# File 'lib/abstract_interface/themed_form_helper.rb', line 39 def line_with_delimiters *items template.render template.themed_partial('forms/line'), :object => {:items => items, :delimiter => true}.to_openobject end |