0

How can you prepopulate a Reform form object with variables from the query string?

I understand how to call prepopulate! but how do I access a variable on the URL from within the Reform contract?

For example:

/example/new?lang=en

property :language, virtual: true, prepopulator: ->(*) { ??? }
Greg Olsen
  • 1,370
  • 17
  • 28

1 Answers1

0

To follow the docs on Trailblazer GitHub:

class AlbumsController
  def new
    @form = AlbumForm.new(Album.new)
  end

should be:

class AlbumsController
  def new
    @form = AlbumForm.new(Album.new(language: params[:lang]))
  end
Eelco
  • 111
  • 1
  • 7