Module: VoiceForm::FormMethods
- Included in:
- Form
- Defined in:
- lib/voice_form/form_methods.rb
Instance Method Summary collapse
-
#field(field_name, options = {}, &block) ⇒ Object
Can be used in a form or stand-alone in a component method.
Instance Method Details
#field(field_name, options = {}, &block) ⇒ Object
Can be used in a form or stand-alone in a component method
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/voice_form/form_methods.rb', line 50 def field(field_name, ={}, &block) raise "A field requires a block" unless block_given? form_field = VoiceForm::FormField.new(field_name, , self, &block) if self.is_a?(VoiceForm::Form) self.form_stack << form_field else unless self.respond_to?(field_name) self.class.class_eval do attr_accessor field_name end end form_field.run end end |