Class: Rad::Face::ThemedFormHelper
- Inherits:
-
Object
- Object
- Rad::Face::ThemedFormHelper
- Defined in:
- lib/face/themed_form_helper.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
Returns the value of attribute template.
Class Method Summary collapse
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
Constructor Details
#initialize(template) ⇒ ThemedFormHelper
Returns a new instance of ThemedFormHelper.
4 5 6 |
# File 'lib/face/themed_form_helper.rb', line 4 def initialize template self.template = template end |
Instance Attribute Details
#template ⇒ Object
Returns the value of attribute template.
2 3 4 |
# File 'lib/face/themed_form_helper.rb', line 2 def template @template end |
Class Method Details
.generate_form_helper_methods(methods) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/face/themed_form_helper.rb', line 39 def self.generate_form_helper_methods methods methods.each do |m| define_method m do |*args| = args. template.capture do form_field do || args << template.concat(template.send(m, *args)) end end end end end |
Instance Method Details
#error_messages(*errors) ⇒ Object
8 9 10 11 |
# File 'lib/face/themed_form_helper.rb', line 8 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
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/face/themed_form_helper.rb', line 13 def form_field , &block = .to_openobject = Rad::Face::HtmlOpenObject.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
34 35 36 37 |
# File 'lib/face/themed_form_helper.rb', line 34 def line *items object = Rad::Face::HtmlOpenObject.initialize_from(items: items) template.render template.themed_partial('/forms/line'), object: object end |