Class: Effective::FormInput
- Inherits:
-
Object
- Object
- Effective::FormInput
show all
- Defined in:
- app/models/effective/form_input.rb
Direct Known Subclasses
Effective::FormInputs::CheckBox, Effective::FormInputs::CkEditor, Effective::FormInputs::Clear, Effective::FormInputs::CollectionInput, Effective::FormInputs::DatetimeField, Effective::FormInputs::Editor, Effective::FormInputs::EmailField, Effective::FormInputs::ErrorField, Effective::FormInputs::FileField, Effective::FormInputs::FloatField, Effective::FormInputs::FormGroup, Effective::FormInputs::IntegerField, Effective::FormInputs::NumberField, Effective::FormInputs::NumberTextField, Effective::FormInputs::PasswordField, Effective::FormInputs::PercentField, Effective::FormInputs::PhoneField, Effective::FormInputs::PriceField, Effective::FormInputs::Reset, Effective::FormInputs::Save, Effective::FormInputs::SearchField, Effective::FormInputs::SelectOrText, Effective::FormInputs::StaticField, Effective::FormInputs::Submit, Effective::FormInputs::TextArea, Effective::FormInputs::TextField, Effective::FormInputs::UrlField
Constant Summary
collapse
- BLANK =
''.html_safe
- EXCLUSIVE_CLASS_PREFIXES =
[]
- EXCLUSIVE_CLASS_SUFFIXES =
['-primary', '-secondary', '-success', '-danger', '-warning', '-info', '-light', '-dark']
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, options, builder:, html_options: nil) ⇒ FormInput
So this takes in the options for an entire form group.
13
14
15
16
17
18
19
20
|
# File 'app/models/effective/form_input.rb', line 13
def initialize(name, options, builder:, html_options: nil)
@builder = builder
@template = builder.template
@name = name
@options = (options, html_options: html_options)
apply_input_options!
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3
4
5
|
# File 'app/models/effective/form_input.rb', line 3
def name
@name
end
|
#options ⇒ Object
Returns the value of attribute options.
3
4
5
|
# File 'app/models/effective/form_input.rb', line 3
def options
@options
end
|
Instance Method Details
#feedback_options ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/models/effective/form_input.rb', line 45
def feedback_options
case layout
when :inline
false
else
{ valid: { class: 'valid-feedback' }, invalid: { class: 'invalid-feedback' } }
end
end
|
#hint_options ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/models/effective/form_input.rb', line 54
def hint_options
case layout
when :inline
{ tag: :small, class: 'text-muted', id: "#{tag_id}_hint" }
else
{ tag: :small, class: 'form-text text-muted', id: "#{tag_id}_hint" }
end
end
|
22
23
24
|
# File 'app/models/effective/form_input.rb', line 22
def input_group_options
{ input_group: { class: 'input-group' }, prepend: false, append: false }
end
|
26
27
28
|
# File 'app/models/effective/form_input.rb', line 26
def input_html_options
{ class: 'form-control' }
end
|
30
31
32
|
# File 'app/models/effective/form_input.rb', line 30
def input_js_options
{}
end
|
#label_options ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'app/models/effective/form_input.rb', line 34
def label_options
case layout
when :horizontal
{ class: 'col-sm-2 col-form-label'}
when :inline
{ class: 'sr-only' }
else
{ }
end
end
|
#to_html(&block) ⇒ Object
72
73
74
|
# File 'app/models/effective/form_input.rb', line 72
def to_html(&block)
wrap(&block)
end
|
#wrapper_options ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'app/models/effective/form_input.rb', line 63
def wrapper_options
case layout
when :horizontal
{ class: 'form-group row' }
else
{ class: 'form-group' }
end
end
|