Sha256: fd67f99840dcdfafbb296c6a1fb0a66aef393d4221bd906fbc5945b710da3c8a

Contents?: true

Size: 718 Bytes

Versions: 4

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module ActiveDryForm
  module FormHelper

    def active_dry_form_for(name, options = {}, &block)
      options[:builder] = ActiveDryForm::Builder
      options[:html] = html_options(options)

      form_for(name, options) do |f|
        concat f.show_base_errors
        instance_exec(f, &block)
      end
    end

    private def html_options(options)
      classes = { class: ActiveDryForm.config.css_classes.form }

      (options[:html] || {}).merge(ActiveDryForm.config.html_options.form, classes) do |_key, oldval, newval|
        Array.wrap(newval) + Array.wrap(oldval)
      end
    end

  end
end

ActiveSupport.on_load(:action_view) do
  include ActiveDryForm::FormHelper
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_dry_form-1.2.1 lib/active_dry_form/form_helper.rb
active_dry_form-1.2.0 lib/active_dry_form/form_helper.rb
active_dry_form-1.1.1 lib/active_dry_form/form_helper.rb
active_dry_form-1.1.0 lib/active_dry_form/form_helper.rb