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

#layoutObject

Returns the value of attribute layout.



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

def layout
  @layout
end

#templateObject

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

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



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

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

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



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

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

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



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

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

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



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

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



58
59
60
# File 'app/models/effective/form_builder.rb', line 58

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

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



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

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



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

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

#save(name = 'Save', options = {}) ⇒ Object



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

def save(name = 'Save', options = {})
  (options = name; name = 'Save') if name.kind_of?(Hash)
  Effective::FormInputs::Save.new(name, options, builder: self).to_html { super(name, options) }
end

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



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

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



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

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

#submit(name = 'Save', options = {}, &block) ⇒ Object



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

def submit(name = 'Save', options = {}, &block)
  (options = name; name = 'Save') if name.kind_of?(Hash)
  Effective::FormInputs::Submit.new(name, options, builder: self).to_html(&block)
end

#super_text_fieldObject



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

alias_method :super_text_field, :text_field

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



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

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

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



97
98
99
# File 'app/models/effective/form_builder.rb', line 97

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

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



101
102
103
# File 'app/models/effective/form_builder.rb', line 101

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

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



105
106
107
# File 'app/models/effective/form_builder.rb', line 105

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