Sha256: f94a2e85d7d5ad389772dbd65f7f2ec24e2d632a73f5d6aebcbfa8120d08a075
Contents?: true
Size: 1.23 KB
Versions: 28
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Ariadne module ActionViewExtensions # :nodoc: module FormHelper include ClassNameHelper DEFAULT_FORM_CLASSES = "ariadne-space-y-8 ariadne-divide-y ariadne-divide-gray-200 sm:ariadne-space-y-5" 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] ||= {} data = options.delete(:data) || {} attributes = attributes.delete_if do |key, value| key_name = key.to_s if key_name.start_with?("data-") data[key_name.sub(/^data-/, "").to_sym] = value true else false end end data[:controller] = if data.fetch(:controller, {}).present? "#{data[:controller]} ariadne-form" else "ariadne-form" end form_with(model: model, scope: scope, url: url, format: format, data: data, attributes: attributes, **options, &block) end end end end ActiveSupport.on_load(:action_view) do include Ariadne::ActionViewExtensions::FormHelper end
Version data entries
28 entries across 28 versions & 1 rubygems