Class: Formic::Input
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Attributes inherited from Base
#content, #options, #page, #template
Instance Method Summary collapse
Methods inherited from Base
#add_class, default_template, #formics, #has_class?, #initialize, #merge_options, #method_missing, template, #to_s
Constructor Details
This class inherits a constructor from Formic::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Formic::Base
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
5 6 7 |
# File 'lib/formic/input.rb', line 5 def field @field end |
Instance Method Details
#_initialize(name = nil, options = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/formic/input.rb', line 12 def _initialize name=nil, ={}, &block if name.instance_of? Hash = name name = nil end super , &block @field = name || [:name] if ![:name] if @field && self.form && self.form.model self.[:name] = "#{self.form.model.class.to_s.downcase}[#{name}]" self.[:value] ||= self.form.model.send(@field.to_sym) elsif self.[:name] = name end end return self end |
#form ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/formic/input.rb', line 33 def form self.formics.each do |element| return element if element.instance_of? Formic::Form end return nil end |
#label ⇒ Object
7 8 9 10 |
# File 'lib/formic/input.rb', line 7 def label return self.[:label] if self.[:label] return @field.underscore.gsub('_', ' ').titleize end |