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
13
14
15
16
17
18
# 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
  @action = options.delete(:action)
  @readonly = options.delete(:readonly)
  @disabled = options.delete(:disabled)
  @remote = options[:remote]

  super
end

Instance Attribute Details

#action ⇒ Object

Returns the value of attribute action.



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

def action
  @action
end

#disabled ⇒ Object

Returns the value of attribute disabled.



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

def disabled
  @disabled
end

#layout ⇒ Object

Returns the value of attribute layout.



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

def layout
  @layout
end

#readonly ⇒ Object

Returns the value of attribute readonly.



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

def readonly
  @readonly
end

#remote ⇒ Object

Returns the value of attribute remote.



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

def remote
  @remote
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



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

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



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

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



31
32
33
# File 'app/models/effective/form_builder.rb', line 31

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

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



35
36
37
# File 'app/models/effective/form_builder.rb', line 35

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

#delete(name = 'Remove', url = nil, options = {}, &block) ⇒ Object



39
40
41
42
# File 'app/models/effective/form_builder.rb', line 39

def delete(name = 'Remove', url = nil, options = {}, &block)
  options[:href] ||= url
  Effective::FormInputs::Delete.new(name, options, builder: self).to_html(&block)
end

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



44
45
46
# File 'app/models/effective/form_builder.rb', line 44

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



48
49
50
# File 'app/models/effective/form_builder.rb', line 48

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

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



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

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



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

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

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



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

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

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



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

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



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

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

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



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

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



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

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



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

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



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

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



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

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



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

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_field ⇒ Object



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

alias_method :super_text_field, :text_field

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



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

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

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



108
109
110
# File 'app/models/effective/form_builder.rb', line 108

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

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



112
113
114
# File 'app/models/effective/form_builder.rb', line 112

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

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



116
117
118
# File 'app/models/effective/form_builder.rb', line 116

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