Class: Primer::Forms::FormControl

Inherits:
BaseComponent show all
Defined in:
lib/primer/forms/form_control.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes included from ActsAsComponent

#template_root_path

Instance Method Summary collapse

Methods inherited from BaseComponent

#content, inherited, #input?, #perform_render, #render?, #to_component, #type

Methods included from ActsAsComponent

#compile!, extended, #renders_templates

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(input:, tag: :div, **system_arguments) ⇒ FormControl

Returns a new instance of FormControl.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/primer/forms/form_control.rb', line 9

def initialize(input:, tag: :div, **system_arguments)
  @input = input
  @tag = tag
  @input.add_label_classes("FormControl-label")
  @form_group_arguments = {
    **system_arguments,
    class: class_names(
      system_arguments[:class],
      system_arguments[:classes],
      "FormControl",
      "width-full",
      "FormControl--fullWidth" => @input.full_width?
    )
  }

  @form_group_arguments[:hidden] = "hidden" if @input.hidden?
end