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



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

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#disabledObject

Returns the value of attribute disabled.



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

def disabled
  @disabled
end

#layoutObject

Returns the value of attribute layout.



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

def layout
  @layout
end

#readonlyObject

Returns the value of attribute readonly.



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

def readonly
  @readonly
end

#remoteObject

Returns the value of attribute remote.



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

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



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

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



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

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



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

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

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



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

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



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

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

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



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

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

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



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

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



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

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

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



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

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

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



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

def float_field(name, options = {})
  Effective::FormInputs::FloatField.new(name, options, builder: self).to_html
end

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



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

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

#hide_if(*args, &block) ⇒ Object

Logics



141
142
143
# File 'app/models/effective/form_builder.rb', line 141

def hide_if(*args, &block)
  Effective::FormLogics::HideIf.new(*args, builder: self).to_html(&block)
end

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



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

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

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



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

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

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



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

def percent_field(name, options = {})
  Effective::FormInputs::PercentField.new(name, options, builder: self).to_html
end

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



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

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

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



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

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



119
120
121
122
# File 'app/models/effective/form_builder.rb', line 119

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

This is gonna be a post?



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

def remote_link_to(name, url, options = {}, &block)
  options[:href] ||= url
  Effective::FormInputs::RemoteLinkTo.new(name, options, builder: self).to_html(&block)
end

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



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

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



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

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

#show_if(*args, &block) ⇒ Object



145
146
147
# File 'app/models/effective/form_builder.rb', line 145

def show_if(*args, &block)
  Effective::FormLogics::ShowIf.new(*args, builder: self).to_html(&block)
end

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



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

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



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

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_number_fieldObject



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

alias_method :super_number_field, :number_field

#super_text_areaObject



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

alias_method :super_text_area, :text_area

#super_text_fieldObject



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

alias_method :super_text_field, :text_field

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



124
125
126
# File 'app/models/effective/form_builder.rb', line 124

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

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



128
129
130
# File 'app/models/effective/form_builder.rb', line 128

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

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



132
133
134
# File 'app/models/effective/form_builder.rb', line 132

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

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



136
137
138
# File 'app/models/effective/form_builder.rb', line 136

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