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::CollectionInput, Effective::FormInputs::DatetimeField, Effective::FormInputs::EmailField, Effective::FormInputs::ErrorField, Effective::FormInputs::FileField, Effective::FormInputs::FormGroup, Effective::FormInputs::NumberField, Effective::FormInputs::PasswordField, Effective::FormInputs::PhoneField, Effective::FormInputs::PriceField, Effective::FormInputs::Save, Effective::FormInputs::StaticField, Effective::FormInputs::Submit, Effective::FormInputs::TextArea, Effective::FormInputs::TextField, Effective::FormInputs::UrlField
Constant Summary
collapse
- BLANK =
''.html_safe
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.
11
12
13
14
15
16
17
18
|
# File 'app/models/effective/form_input.rb', line 11
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
43
44
45
46
47
48
49
50
|
# File 'app/models/effective/form_input.rb', line 43
def feedback_options
case layout
when :inline
false
else
{ valid: { class: 'valid-feedback' }, invalid: { class: 'invalid-feedback' } }
end
end
|
#hint_options ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'app/models/effective/form_input.rb', line 52
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
|
20
21
22
|
# File 'app/models/effective/form_input.rb', line 20
def input_group_options
{ input_group: { class: 'input-group' }, prepend: false, append: false }
end
|
24
25
26
|
# File 'app/models/effective/form_input.rb', line 24
def input_html_options
{ class: 'form-control' }
end
|
28
29
30
|
# File 'app/models/effective/form_input.rb', line 28
def input_js_options
{}
end
|
#label_options ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'app/models/effective/form_input.rb', line 32
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
70
71
72
|
# File 'app/models/effective/form_input.rb', line 70
def to_html(&block)
wrap(&block)
end
|
#wrapper_options ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'app/models/effective/form_input.rb', line 61
def wrapper_options
case layout
when :horizontal
{ class: 'form-group row' }
else
{ class: 'form-group' }
end
end
|