Sha256: ce31ebd373eed03b9688fe2bcd4c5901dc3e29dcdc4810910aa3068723fb93ac

Contents?: true

Size: 961 Bytes

Versions: 116

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

module Ariadne
  module ActionViewExtensions
    # :nodoc:
    module FormHelper
      include ClassNameHelper

      DEFAULT_FORM_CLASSES = "ariadne-space-y-8 sm:ariadne-space-y-5"
      def ariadne_form_with(model: nil, scope: nil, url: nil, format: nil, classes: "", attributes: {}, **options, &block)
        options[:class] = merge_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
    end
  end
end

ActiveSupport.on_load(:action_view) do
  include Ariadne::ActionViewExtensions::FormHelper
end

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.37-x86_64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.37-x86_64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.37-arm64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.37-x64-mingw32 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.37 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36-x64-mingw-ucrt app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36-x64-mingw32 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36-x86_64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36-x86_64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36-arm64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.36-aarch64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.35-x64-mingw32 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.35-x64-mingw-ucrt app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.35-arm64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.35-aarch64-linux app/lib/ariadne/action_view_extensions/form_helper.rb