Class: Effective::FormInput
- Inherits:
-
Object
- Object
- Effective::FormInput
show all
- Defined in:
- app/models/effective/form_input.rb
Direct Known Subclasses
Effective::FormInputs::ArticleEditor, Effective::FormInputs::CheckBox, Effective::FormInputs::CkEditor, Effective::FormInputs::Clear, Effective::FormInputs::CollectionInput, Effective::FormInputs::DatetimeField, Effective::FormInputs::Editor, Effective::FormInputs::EmailCcField, Effective::FormInputs::EmailField, Effective::FormInputs::ErrorField, Effective::FormInputs::FileField, Effective::FormInputs::FloatField, Effective::FormInputs::FormGroup, Effective::FormInputs::HasMany, Effective::FormInputs::HiddenField, 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::RichTextArea, 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
- EMPTY_HASH =
{}
- EXCLUSIVE_CLASS_PREFIXES =
[]
- EXCLUSIVE_CLASS_SUFFIXES =
['-primary', '-secondary', '-success', '-danger', '-warning', '-info', '-light', '-dark', '-link']
- DEFAULT_INPUT_GROUP_OPTIONS =
{ input_group: { class: 'input-group' }, prepend: false, append: false }
- HORIZONTAL_LABEL_OPTIONS =
{ class: 'col-sm-2 col-form-label'}
- INLINE_LABEL_OPTIONS =
{ class: 'sr-only' }
- DEFAULT_FEEDBACK_OPTIONS =
{ valid: { class: 'valid-feedback' }, invalid: { class: 'invalid-feedback' } }
- HORIZONTAL_WRAPPER_OPTIONS =
{ class: 'form-group row' }
- VERTICAL_WRAPPER_OPTIONS =
{ class: 'form-group' }
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.
27
28
29
30
31
32
33
34
|
# File 'app/models/effective/form_input.rb', line 27
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.
5
6
7
|
# File 'app/models/effective/form_input.rb', line 5
def name
@name
end
|
#options ⇒ Object
Returns the value of attribute options.
5
6
7
|
# File 'app/models/effective/form_input.rb', line 5
def options
@options
end
|
Instance Method Details
#feedback_options ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'app/models/effective/form_input.rb', line 59
def feedback_options
case layout
when :inline
false
else
DEFAULT_FEEDBACK_OPTIONS
end
end
|
#hint_options ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'app/models/effective/form_input.rb', line 68
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
|
40
41
42
|
# File 'app/models/effective/form_input.rb', line 40
def input_html_options
{ class: 'form-control', id: tag_id }
end
|
44
45
46
|
# File 'app/models/effective/form_input.rb', line 44
def input_js_options
EMPTY_HASH
end
|
#to_html(&block) ⇒ Object
86
87
88
|
# File 'app/models/effective/form_input.rb', line 86
def to_html(&block)
wrap(&block)
end
|
#wrapper_options ⇒ Object