Class: AppFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/helpers/app_form_builder.rb,
lib/generators/quicksilver_ui/form/templates/app_form_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.with_blank_error_proc(&block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/app_form_builder.rb', line 4

def self.with_blank_error_proc(&block)
  old_error_proc = ActionView::Base.field_error_proc
  begin
    ActionView::Base.field_error_proc = proc do |tag, instance|
      tag
    end
    block.call
  ensure
    ActionView::Base.field_error_proc = old_error_proc
  end
end

Instance Method Details

#checkbox(method, options = {}) ⇒ Object



83
84
85
# File 'app/helpers/app_form_builder.rb', line 83

def checkbox(method, options = {})
  render Form::Checkbox.new(form: self, method:, **options)
end

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



24
25
26
# File 'app/helpers/app_form_builder.rb', line 24

def date_field(method, options = {})
  render Form::DateField.new(form: self, method:, **options)
end

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



28
29
30
# File 'app/helpers/app_form_builder.rb', line 28

def email_field(method, options = {})
  render Form::EmailField.new(form: self, method:, **options)
end

#error(method, text = nil, options = {}, &block) ⇒ Object



75
76
77
# File 'app/helpers/app_form_builder.rb', line 75

def error(method, text = nil, options = {}, &block)
  render Form::Error.new(form: self, method:, text:, **options)
end

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



36
37
38
# File 'app/helpers/app_form_builder.rb', line 36

def file_field(method, options = {})
  render Form::FileField.new(form: self, method:, **options)
end

#group(method, options = {}) ⇒ Object



16
17
18
# File 'app/helpers/app_form_builder.rb', line 16

def group(method, options = {})
  render Form::Group.new(form: self, method:, type: options[:type] || :text, **options.except(:type))
end

#hint(method, text = nil, options = {}, &block) ⇒ Object



71
72
73
# File 'app/helpers/app_form_builder.rb', line 71

def hint(method, text = nil, options = {}, &block)
  render Form::Hint.new(form: self, method:, text:, **options)
end

#label(method, text = nil, options = {}, &block) ⇒ Object



67
68
69
# File 'app/helpers/app_form_builder.rb', line 67

def label(method, text = nil, options = {}, &block)
  render Form::Label.new(form: self, method:, text:, **options)
end

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



40
41
42
# File 'app/helpers/app_form_builder.rb', line 40

def password_field(method, options = {})
  render Form::PasswordField.new(form: self, method:, **options)
end

#phone_field(method, options = {}) ⇒ Object



32
33
34
# File 'app/helpers/app_form_builder.rb', line 32

def phone_field(method, options = {})
  render Form::PhoneField.new(form: self, method:, **options)
end

#radio_button(method, tag_value, options = {}) ⇒ Object



91
92
93
# File 'app/helpers/app_form_builder.rb', line 91

def radio_button(method, tag_value, options = {})
  render Form::RadioButton.new(form: self, tag_value:, method:, **options)
end

#search_field(method, options = {}) ⇒ Object



44
45
46
# File 'app/helpers/app_form_builder.rb', line 44

def search_field(method, options = {})
  render Form::SearchField.new(form: self, method:, **options)
end

#select(method, choices = nil, options = {}, html_options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/app_form_builder.rb', line 48

def select(method, choices = nil, options = {}, html_options = {})
  render Form::Select.new(
    form: self,
    method:,
    choices:,
    selected: options[:selected],
    include_blank: options.fetch(:include_blank, true),
    prompt: options[:prompt],
    disabled: options[:disabled],
    include_hidden: options.fetch(:include_hidden, true),
    html_options:
  )
end

#submit(value = nil, options = {}) ⇒ Object



79
80
81
# File 'app/helpers/app_form_builder.rb', line 79

def submit(value = nil, options = {})
  super(value, options.with_defaults(class: "ui-button ui-button-primary"))
end

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



20
21
22
# File 'app/helpers/app_form_builder.rb', line 20

def text_field(method, options = {})
  render Form::TextField.new(form: self, method:, **options)
end

#textarea(method, options = {}) ⇒ Object Also known as: text_area



62
63
64
# File 'app/helpers/app_form_builder.rb', line 62

def textarea(method, options = {})
  render Form::Textarea.new(form: self, method:, **options)
end

#toggle(method, options = {}) ⇒ Object



87
88
89
# File 'app/helpers/app_form_builder.rb', line 87

def toggle(method, options = {})
  render Form::Toggle.new(form: self, method:, **options)
end