Module: Bureaucrat::Quickfields
- Includes:
- Fields
- Defined in:
- lib/bureaucrat/quickfields.rb
Overview
Shortcuts for declaring form fields
Instance Method Summary collapse
-
#boolean(name, options = {}) ⇒ Object
Declare a
BooleanField. -
#checkbox_multiple_choice(name, choices = [], options = {}) ⇒ Object
Declare a
MultipleChoiceFieldwith theCheckboxSelectMultiplewidget. -
#choice(name, choices = [], options = {}) ⇒ Object
Declare a
ChoiceFieldwithchoices. -
#decimal(name, options = {}) ⇒ Object
Declare a
BigDecimalField. -
#delete(name) ⇒ Object
Delete field named
name. -
#email(name, options = {}) ⇒ Object
Declare an
EmailField. -
#file(name, options = {}) ⇒ Object
Declare a
FileField. -
#hide(name) ⇒ Object
Hide field named
name. -
#integer(name, options = {}) ⇒ Object
Declare an
IntegerField. -
#multiple_choice(name, choices = [], options = {}) ⇒ Object
Declare a
MultipleChoiceFieldwithchoices. -
#null_boolean(name, options = {}) ⇒ Object
Declare a
NullBooleanField. -
#password(name, options = {}) ⇒ Object
Declare a
CharFieldwith password widget. -
#radio_choice(name, choices = [], options = {}) ⇒ Object
Declare a
ChoiceFieldusing theRadioSelectwidget. -
#regex(name, regexp, options = {}) ⇒ Object
Declare a
RegexField. -
#string(name, options = {}) ⇒ Object
Declare a
CharFieldwith text input widget. -
#text(name, options = {}) ⇒ Object
Declare a
CharFieldwith text area widget. -
#typed_choice(name, choices = [], options = {}) ⇒ Object
Declare a
TypedChoiceFieldwithchoices.
Instance Method Details
#boolean(name, options = {}) ⇒ Object
Declare a BooleanField
58 59 60 |
# File 'lib/bureaucrat/quickfields.rb', line 58 def boolean(name, = {}) field name, BooleanField.new() end |
#checkbox_multiple_choice(name, choices = [], options = {}) ⇒ Object
Declare a MultipleChoiceField with the CheckboxSelectMultiple widget
88 89 90 |
# File 'lib/bureaucrat/quickfields.rb', line 88 def checkbox_multiple_choice(name, choices = [], = {}) field name, MultipleChoiceField.new(choices, .merge(widget: Widgets::CheckboxSelectMultiple.new)) end |
#choice(name, choices = [], options = {}) ⇒ Object
Declare a ChoiceField with choices
68 69 70 |
# File 'lib/bureaucrat/quickfields.rb', line 68 def choice(name, choices = [], = {}) field name, ChoiceField.new(choices, ) end |
#decimal(name, options = {}) ⇒ Object
Declare a BigDecimalField
38 39 40 |
# File 'lib/bureaucrat/quickfields.rb', line 38 def decimal(name, = {}) field name, BigDecimalField.new() end |
#delete(name) ⇒ Object
Delete field named name
13 14 15 |
# File 'lib/bureaucrat/quickfields.rb', line 13 def delete(name) base_fields.delete name end |
#email(name, options = {}) ⇒ Object
Declare an EmailField
48 49 50 |
# File 'lib/bureaucrat/quickfields.rb', line 48 def email(name, = {}) field name, EmailField.new() end |
#file(name, options = {}) ⇒ Object
Declare a FileField
53 54 55 |
# File 'lib/bureaucrat/quickfields.rb', line 53 def file(name, = {}) field name, FileField.new() end |
#hide(name) ⇒ Object
Hide field named name
7 8 9 10 |
# File 'lib/bureaucrat/quickfields.rb', line 7 def hide(name) base_fields[name] = base_fields[name].dup base_fields[name]. = Widgets::HiddenInput.new end |
#integer(name, options = {}) ⇒ Object
Declare an IntegerField
33 34 35 |
# File 'lib/bureaucrat/quickfields.rb', line 33 def integer(name, = {}) field name, IntegerField.new() end |
#multiple_choice(name, choices = [], options = {}) ⇒ Object
Declare a MultipleChoiceField with choices
78 79 80 |
# File 'lib/bureaucrat/quickfields.rb', line 78 def multiple_choice(name, choices = [], = {}) field name, MultipleChoiceField.new(choices, ) end |
#null_boolean(name, options = {}) ⇒ Object
Declare a NullBooleanField
63 64 65 |
# File 'lib/bureaucrat/quickfields.rb', line 63 def null_boolean(name, = {}) field name, NullBooleanField.new() end |
#password(name, options = {}) ⇒ Object
Declare a CharField with password widget
28 29 30 |
# File 'lib/bureaucrat/quickfields.rb', line 28 def password(name, = {}) field name, CharField.new(.merge(widget: Widgets::PasswordInput.new)) end |
#radio_choice(name, choices = [], options = {}) ⇒ Object
Declare a ChoiceField using the RadioSelect widget
83 84 85 |
# File 'lib/bureaucrat/quickfields.rb', line 83 def radio_choice(name, choices = [], = {}) field name, ChoiceField.new(choices, .merge(widget: Widgets::RadioSelect.new)) end |
#regex(name, regexp, options = {}) ⇒ Object
Declare a RegexField
43 44 45 |
# File 'lib/bureaucrat/quickfields.rb', line 43 def regex(name, regexp, = {}) field name, RegexField.new(regexp, ) end |
#string(name, options = {}) ⇒ Object
Declare a CharField with text input widget
18 19 20 |
# File 'lib/bureaucrat/quickfields.rb', line 18 def string(name, = {}) field name, CharField.new() end |
#text(name, options = {}) ⇒ Object
Declare a CharField with text area widget
23 24 25 |
# File 'lib/bureaucrat/quickfields.rb', line 23 def text(name, = {}) field name, CharField.new(.merge(widget: Widgets::Textarea.new)) end |
#typed_choice(name, choices = [], options = {}) ⇒ Object
Declare a TypedChoiceField with choices
73 74 75 |
# File 'lib/bureaucrat/quickfields.rb', line 73 def typed_choice(name, choices = [], = {}) field name, TypedChoiceField.new(choices, ) end |