Module: Primer::Forms::Dsl::InputMethods

Included in:
Alpha::MultiInput, FormObject, InputGroup, MultiInput
Defined in:
lib/primer/forms/dsl/input_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#action_menu(**options, &block) ⇒ Object

Adds an <%= link_to_component(Primer::Alpha::ActionMenu) %> to this form.

Parameters:

  • options (Hash)

    The options accepted by the <%= link_to_component(Primer::Alpha::ActionMenu) %> component.

  • block (Proc)

    The block passed to ‘#render` when the <%= link_to_component(Primer::Alpha::ActionMenu) %> is rendered. This block is passed an instance of <%= link_to_component(Primer::Alpha::ActionMenu) %>, which can be used to add items, dividers, etc.



97
98
99
100
# File 'lib/primer/forms/dsl/input_methods.rb', line 97

def action_menu(**options, &block)
  options = decorate_options(**options)
  add_input ActionMenuInput.new(builder: builder, form: form, **options, &block)
end

#button(**options, &block) ⇒ Object

Adds a (non-submit) button to this form.

Parameters:

  • options (Hash)

    The options accepted by the button input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



119
120
121
122
# File 'lib/primer/forms/dsl/input_methods.rb', line 119

def button(**options, &block)
  options = decorate_options(**options)
  add_input ButtonInput.new(builder: builder, form: form, **options, &block)
end

#check_box(**options, &block) ⇒ Object

Adds a check box to this form.

Parameters:

  • options (Hash)

    The options accepted by the check box input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



35
36
37
# File 'lib/primer/forms/dsl/input_methods.rb', line 35

def check_box(**options, &block)
  add_input CheckBoxInput.new(builder: builder, form: form, **options, &block)
end

#check_box_group(**options, &block) ⇒ Object

Adds a check box group to this form.

Parameters:

  • options (Hash)

    The options accepted by the check box group input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



51
52
53
# File 'lib/primer/forms/dsl/input_methods.rb', line 51

def check_box_group(**options, &block)
  add_input CheckBoxGroupInput.new(builder: builder, form: form, **options, &block)
end

#fields_for(*args, **kwargs, &block) ⇒ Object

Used to render another form object.

Parameters:



12
13
14
# File 'lib/primer/forms/dsl/input_methods.rb', line 12

def fields_for(*args, **kwargs, &block)
  add_input FormReferenceInput.new(*args, builder: builder, form: form, **kwargs, &block)
end

#hidden(**options) ⇒ Object

Adds a hidden input to this form.

Parameters:

  • options (Hash)

    The options accepted by the hidden input (see forms docs).



27
28
29
# File 'lib/primer/forms/dsl/input_methods.rb', line 27

def hidden(**options)
  add_input HiddenInput.new(builder: builder, form: form, **options)
end

#inputsObject



127
128
129
# File 'lib/primer/forms/dsl/input_methods.rb', line 127

def inputs
  @inputs ||= []
end

#multi(**options, &block) ⇒ Object

Adds a multi input to this form.

Parameters:

  • options (Hash)

    The options accepted by the multi input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



20
21
22
# File 'lib/primer/forms/dsl/input_methods.rb', line 20

def multi(**options, &block)
  add_input MultiInput.new(builder: builder, form: form, **options, &block)
end

#radio_button_group(**options, &block) ⇒ Object

Adds a radio button group to this form.

Parameters:

  • options (Hash)

    The options accepted by the radio button group input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



43
44
45
# File 'lib/primer/forms/dsl/input_methods.rb', line 43

def radio_button_group(**options, &block)
  add_input RadioButtonGroupInput.new(builder: builder, form: form, **options, &block)
end

#select_list(**options, &block) ⇒ Object

Adds a select list to this form.

Parameters:

  • options (Hash)

    The options accepted by the select list input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



88
89
90
91
# File 'lib/primer/forms/dsl/input_methods.rb', line 88

def select_list(**options, &block)
  options = decorate_options(**options)
  add_input SelectInput.new(builder: builder, form: form, **options, &block)
end

#separatorObject

Adds a horizontal separator to the form.



56
57
58
# File 'lib/primer/forms/dsl/input_methods.rb', line 56

def separator
  add_input Separator.new
end

#submit(**options, &block) ⇒ Object

Adds a submit button to this form.

Parameters:

  • options (Hash)

    The options accepted by the submit button input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



110
111
112
113
# File 'lib/primer/forms/dsl/input_methods.rb', line 110

def submit(**options, &block)
  options = decorate_options(**options)
  add_input SubmitButtonInput.new(builder: builder, form: form, **options, &block)
end

#text_area(**options, &block) ⇒ Object

Adds a text area to this form.

Parameters:

  • options (Hash)

    The options accepted by the text area input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



75
76
77
78
# File 'lib/primer/forms/dsl/input_methods.rb', line 75

def text_area(**options, &block)
  options = decorate_options(**options)
  add_input TextAreaInput.new(builder: builder, form: form, **options, &block)
end

#text_field(**options, &block) ⇒ Object

Adds a text field to this form.

Parameters:

  • options (Hash)

    The options accepted by the text field input (see forms docs).

  • block (Proc)

    A block that will be yielded a reference to the input object so it can be customized.



66
67
68
69
# File 'lib/primer/forms/dsl/input_methods.rb', line 66

def text_field(**options, &block)
  options = decorate_options(**options)
  add_input TextFieldInput.new(builder: builder, form: form, **options, &block)
end