Module: ViewComponent::ComponentHelper
- Included in:
- InputComponent::DatePickerComponent, InputComponent::DropdownComponent, InputComponent::FileSelectorComponent, InputComponent::InputCheckboxComponent, InputComponent::InputRadioComponent, InputComponent::InputTextComponent, InputComponent::TextareaComponent, ProfileIconComponent::ProfileIconComponent
- Defined in:
- app/helpers/view_component/component_helper.rb
Overview
To be used only within a component class such as ButtonComponent
Instance Method Summary collapse
Instance Method Details
#class_list(base, *styles) ⇒ Object
6 7 8 9 |
# File 'app/helpers/view_component/component_helper.rb', line 6 def class_list(base, *styles) base.concat(styles.compact) base.join(' ') end |
#resolve_error(form, name, explicit_error) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/view_component/component_helper.rb', line 11 def resolve_error(form, name, explicit_error) return explicit_error if explicit_error.present? return if form.blank? || form.object.blank? || name.blank? attribute = name.to_s.split('[').last.delete(']').humanize = form.object.errors[name].first .present? ? "#{attribute} #{message}" : nil end |