Class: SexyForm::Themes::SemanticUIInline
- Defined in:
- lib/sexy_form/themes/semantic_ui_inline.rb
Instance Method Summary collapse
- #build_html_error(error:, html_attrs:, field_type:) ⇒ Object
- #build_html_help_text(help_text:, html_attrs:, field_type:) ⇒ Object
- #form_html_attributes(html_attrs:) ⇒ Object
- #input_html_attributes(html_attrs:, field_type:, has_errors:) ⇒ Object
- #label_html_attributes(html_attrs:, field_type:, has_errors:) ⇒ Object
- #wrap_field(field_type:, html_field:, html_label:, html_help_text: nil, html_errors: nil, wrapper_html_attributes:) ⇒ Object
Methods inherited from BaseTheme
Instance Method Details
#build_html_error(error:, html_attrs:, field_type:) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/sexy_form/themes/semantic_ui_inline.rb', line 51 def build_html_error(error:, html_attrs:, field_type:) html_attrs["style"] = "color: red; #{html_attrs["style"]}".strip s = "" s << (html_attrs.empty? ? "<div>" : "<div #{SexyForm.build_html_attr_string(html_attrs)}>") s << "#{error}" s << "</div>" s end |
#build_html_help_text(help_text:, html_attrs:, field_type:) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/sexy_form/themes/semantic_ui_inline.rb', line 43 def build_html_help_text(help_text:, html_attrs:, field_type:) s = "" s << (html_attrs.empty? ? "<div>" : "<div #{SexyForm.build_html_attr_string(html_attrs)}>") s << "#{help_text}" s << "</div>" s end |
#form_html_attributes(html_attrs:) ⇒ Object
38 39 40 41 |
# File 'lib/sexy_form/themes/semantic_ui_inline.rb', line 38 def form_html_attributes(html_attrs:) html_attrs["class"] = "ui form #{html_attrs["class"]}".strip html_attrs end |
#input_html_attributes(html_attrs:, field_type:, has_errors:) ⇒ Object
30 31 32 |
# File 'lib/sexy_form/themes/semantic_ui_inline.rb', line 30 def input_html_attributes(html_attrs:, field_type:, has_errors:) html_attrs end |
#label_html_attributes(html_attrs:, field_type:, has_errors:) ⇒ Object
34 35 36 |
# File 'lib/sexy_form/themes/semantic_ui_inline.rb', line 34 def label_html_attributes(html_attrs:, field_type:, has_errors:) html_attrs end |
#wrap_field(field_type:, html_field:, html_label:, html_help_text: nil, html_errors: nil, wrapper_html_attributes:) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sexy_form/themes/semantic_ui_inline.rb', line 5 def wrap_field(field_type:, html_field:, html_label:, html_help_text: nil, html_errors: nil, wrapper_html_attributes:) s = "" wrapper_html_attributes["class"] = "inline field#{" error" if html_errors} #{wrapper_html_attributes["class"]}".strip attr_str = SexyForm.build_html_attr_string(wrapper_html_attributes) s << "#{attr_str.empty? ? "<div>" : "<div #{attr_str}>"}" if ["checkbox", "radio"].include?(field_type) s << %Q(<div class="ui checkbox#{" radio" if field_type == "radio"}">) s << "#{html_field}" s << "#{html_label}" s << "</div>" else s << "#{html_label}" s << "#{html_field}" end s << "#{html_help_text}" s << html_errors.join if html_errors s << "</div>" s end |