Module: Ariadne::Forms::Dsl::InputMethods

Included in:
ClipboardCopyButton, FormObject, InputGroup, Status
Defined in:
lib/ariadne/forms/dsl/input_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

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

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

Parameters:

  • options (Hash)

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

  • block (Proc)

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



106
107
108
109
# File 'lib/ariadne/forms/dsl/input_methods.rb', line 106

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

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

Adds an autocomplete text field to this form.

Parameters:

  • options (Hash)

    The options accepted by the autocomplete 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/ariadne/forms/dsl/input_methods.rb', line 75

def auto_complete(**options, &block)
  options = decorate_options(**options)
  add_input(AutoCompleteInput.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.



132
133
134
135
# File 'lib/ariadne/forms/dsl/input_methods.rb', line 132

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/ariadne/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/ariadne/forms/dsl/input_methods.rb', line 51

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

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



137
138
139
# File 'lib/ariadne/forms/dsl/input_methods.rb', line 137

def clipboard_copy_button(**options, &block)
  add_input(ClipboardCopyButton.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/ariadne/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/ariadne/forms/dsl/input_methods.rb', line 27

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

#inputsObject



144
145
146
# File 'lib/ariadne/forms/dsl/input_methods.rb', line 144

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/ariadne/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/ariadne/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.



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

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/ariadne/forms/dsl/input_methods.rb', line 56

def separator
  add_input(Separator.new)
end

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



124
125
126
# File 'lib/ariadne/forms/dsl/input_methods.rb', line 124

def status(**options, &block)
  add_input(Status.new(builder: @builder, form: @form, **options, &block))
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.



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

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.



84
85
86
87
# File 'lib/ariadne/forms/dsl/input_methods.rb', line 84

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/ariadne/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