Class: Effective::FormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/models/effective/form_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_name, object, template, options) ⇒ FormBuilder

Returns a new instance of FormBuilder.



8
9
10
11
12
# File 'app/models/effective/form_builder.rb', line 8

def initialize(object_name, object, template, options)
  @template = template
  @layout = (options.delete(:layout) || :vertical).to_sym
  super
end

Instance Attribute Details

#layout ⇒ Object

Returns the value of attribute layout.



4
5
6
# File 'app/models/effective/form_builder.rb', line 4

def layout
  @layout
end

#template ⇒ Object

Returns the value of attribute template.



4
5
6
# File 'app/models/effective/form_builder.rb', line 4

def template
  @template
end

Instance Method Details

#check_box(name, options = {}) ⇒ Object



16
17
18
# File 'app/models/effective/form_builder.rb', line 16

def check_box(name, options = {})
  Effective::FormInputs::CheckBox.new(name, options, builder: self).to_html { super(name, options) }
end

#checks(name, choices = nil, *args) ⇒ Object



20
21
22
23
# File 'app/models/effective/form_builder.rb', line 20

def checks(name, choices = nil, *args)
  options = args.extract_options!.merge!(collection: choices)
  Effective::FormInputs::Checks.new(name, options, builder: self).to_html
end

#date_field(name, options = {}) ⇒ Object



25
26
27
# File 'app/models/effective/form_builder.rb', line 25

def date_field(name, options = {})
  Effective::FormInputs::DateField.new(name, options, builder: self).to_html { super(name, options) }
end

#datetime_field(name, options = {}) ⇒ Object



29
30
31
# File 'app/models/effective/form_builder.rb', line 29

def datetime_field(name, options = {})
  Effective::FormInputs::DatetimeField.new(name, options, builder: self).to_html { super(name, options) }
end

#email_field(name, options = {}) ⇒ Object



33
34
35
# File 'app/models/effective/form_builder.rb', line 33

def email_field(name, options = {})
  Effective::FormInputs::EmailField.new(name, options, builder: self).to_html { super(name, options) }
end

#error(name = nil, options = {}) ⇒ Object Also known as: errors



37
38
39
# File 'app/models/effective/form_builder.rb', line 37

def error(name = nil, options = {})
  Effective::FormInputs::ErrorField.new(name, options, builder: self).to_html()
end

#form_group(name = nil, options = {}, &block) ⇒ Object



42
43
44
# File 'app/models/effective/form_builder.rb', line 42

def form_group(name = nil, options = {}, &block)
  Effective::FormInputs::FormGroup.new(name, options, builder: self).to_html(&block)
end

#number_field(name, options = {}) ⇒ Object



46
47
48
# File 'app/models/effective/form_builder.rb', line 46

def number_field(name, options = {})
  Effective::FormInputs::NumberField.new(name, options, builder: self).to_html { super(name, options) }
end

#password_field(name, options = {}) ⇒ Object



50
51
52
# File 'app/models/effective/form_builder.rb', line 50

def password_field(name, options = {})
  Effective::FormInputs::PasswordField.new(name, options, builder: self).to_html { super(name, options) }
end

#phone_field(name, options = {}) ⇒ Object Also known as: tel_field, telephone_field



54
55
56
# File 'app/models/effective/form_builder.rb', line 54

def phone_field(name, options = {})
  Effective::FormInputs::PhoneField.new(name, options, builder: self).to_html { super(name, options) }
end

#price_field(name, options = {}) ⇒ Object



60
61
62
# File 'app/models/effective/form_builder.rb', line 60

def price_field(name, options = {})
  Effective::FormInputs::PriceField.new(name, options, builder: self).to_html { super(name, options) }
end

#radios(name, choices = nil, *args) ⇒ Object



77
78
79
80
# File 'app/models/effective/form_builder.rb', line 77

def radios(name, choices = nil, *args)
  options = args.extract_options!.merge!(collection: choices)
  Effective::FormInputs::Radios.new(name, options, builder: self).to_html
end

#select(name, choices = nil, *args) ⇒ Object



64
65
66
67
# File 'app/models/effective/form_builder.rb', line 64

def select(name, choices = nil, *args)
  options = args.extract_options!.merge!(collection: choices)
  Effective::FormInputs::Select.new(name, options, builder: self).to_html
end

#static_field(name, options = {}, &block) ⇒ Object



73
74
75
# File 'app/models/effective/form_builder.rb', line 73

def static_field(name, options = {}, &block)
  Effective::FormInputs::StaticField.new(name, options, builder: self).to_html(&block)
end

#submit(name = 'Submit', options = {}) ⇒ Object



69
70
71
# File 'app/models/effective/form_builder.rb', line 69

def submit(name = 'Submit', options = {})
  Effective::FormInputs::Submit.new(name, options, builder: self).to_html { super(name, options) }
end

#super_text_field ⇒ Object



14
# File 'app/models/effective/form_builder.rb', line 14

alias_method :super_text_field, :text_field

#text_area(name, options = {}) ⇒ Object



82
83
84
# File 'app/models/effective/form_builder.rb', line 82

def text_area(name, options = {})
  Effective::FormInputs::TextArea.new(name, options, builder: self).to_html { super(name, options) }
end

#text_field(name, options = {}) ⇒ Object



86
87
88
# File 'app/models/effective/form_builder.rb', line 86

def text_field(name, options = {})
  Effective::FormInputs::TextField.new(name, options, builder: self).to_html { super(name, options) }
end

#time_field(name, options = {}) ⇒ Object



90
91
92
# File 'app/models/effective/form_builder.rb', line 90

def time_field(name, options = {})
  Effective::FormInputs::TimeField.new(name, options, builder: self).to_html { super(name, options) }
end

#url_field(name, options = {}) ⇒ Object



94
95
96
# File 'app/models/effective/form_builder.rb', line 94

def url_field(name, options = {})
  Effective::FormInputs::UrlField.new(name, options, builder: self).to_html { super(name, options) }
end