Sha256: 39af0e9c695e943a386e0dd35e20dde622c11ba85e8288498b162e59631cebb7

Contents?: true

Size: 780 Bytes

Versions: 5

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  ##
  # A factory class for Hyrax forms.
  #
  # @note We use a factory class (rather than a factory method like `.for`) to
  #   provide compatibility with the legacy `Hyrax::WorkFormService`.
  #
  # @example
  #   factory = Hyrax::FormFactory.new
  #
  #   form_change_set = factory.build(work)
  #
  # @since 3.0.0
  class FormFactory
    ##
    # Builds and prepopulates a form for the given model.
    #
    # @param model      [Object]
    # @param ability    [Hyrax::Ability]
    # @param controller [ApplicationController]
    #
    # @see https://trailblazer.to/2.0/gems/reform/prepopulator.html
    def build(model, _ability, _controller)
      Hyrax::Forms::ResourceForm.for(resource: model).prepopulate!
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hyrax-5.0.3 app/services/hyrax/form_factory.rb
hyrax-5.0.2 app/services/hyrax/form_factory.rb
hyrax-5.0.1 app/services/hyrax/form_factory.rb
hyrax-5.0.0 app/services/hyrax/form_factory.rb
hyrax-5.0.0.rc3 app/services/hyrax/form_factory.rb