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.52 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.52-x64-mingw-ucrt app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.51-x64-mingw-ucrt app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.51-x86_64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.51-arm64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.51-aarch64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.51 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.51-x86_64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.50 app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.50-arm64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.50-x64-mingw-ucrt app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.50-x86_64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.50-x86_64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.50-aarch64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.49-aarch64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.49-x86_64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.49-x86_64-linux app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.49-arm64-darwin app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.49-x64-mingw-ucrt app/lib/ariadne/action_view_extensions/form_helper.rb
ariadne_view_components-0.0.49 app/lib/ariadne/action_view_extensions/form_helper.rb