Module: Ariadne::ActionViewExtensions::FormHelper

Includes:
ClassNameHelper
Included in:
Component
Defined in:
app/lib/ariadne/action_view_extensions/form_helper.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_FORM_CLASSES =
"ariadne-space-y-8 sm:ariadne-space-y-5"

Instance Method Summary collapse

Methods included from ClassNameHelper

#class_names

Instance Method Details

#ariadne_form_with(model: nil, scope: nil, url: nil, format: nil, classes: "", attributes: {}, **options, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/lib/ariadne/action_view_extensions/form_helper.rb', line 10

def ariadne_form_with(model: nil, scope: nil, url: nil, format: nil, classes: "", attributes: {}, **options, &block)
  options[:class] = class_names(DEFAULT_FORM_CLASSES, options[:class])
  options[:builder] ||= Ariadne::FormBuilder
  options[:html] = attributes

  data_controller = options[:html].fetch(:"data-controller", "")
  options[:html][:"data-controller"] = if data_controller.present?
    "#{data_controller} ariadne-form"
  else
    "ariadne-form"
  end

  form_with(model: model, scope: scope, url: url, format: format, **options, &block)
end