Reform is a ruby gem for creating form objects decoupled from persistence models.
Questions tagged [reform]
53 questions
11
votes
1 answer
Using the reform gem with Rails, how do I populate a has_many :through nested model
I have a user model and role model, connected in ActiveRecord by:
has_many roles, through: :role_accounts
I want to have an "Edit User" screen that has a list of checkboxes, one for each role. Using the Reform gem (v2.1.0), this a snippet of the…

sockmonk
- 4,195
- 24
- 40
6
votes
2 answers
Rails form object with reform-rails with collections not working or validating
I am using the reform-rails gem In order to utilize a form object in my rails project.
I realize a form object is probably overkill for the example code I use below, but it is for demonstration purposes.
In the form I am creating a user, and…

Neil
- 4,578
- 14
- 70
- 155
4
votes
0 answers
How to always pre-populate nested form attributes with the Reform gem?
I have a Financing model with has_many: :professional_investments.
To edit the Financing, the main form has a nested form for the professional_investments.
I decided to display a fixed list of 8 professional_investments for now, as the Cocoon gem…

Tiago
- 365
- 1
- 8
4
votes
2 answers
How to use Reform to prepopulate for featured objects?
When a user clicks, for example, "Take a Picture" how can we prepopulate the create.html.erb form with attributes specifically set for that featured challenge, like do for 12 days and do on Tue, Thu?
I am using the reform…

AnthonyGalli.com
- 2,796
- 5
- 31
- 80
3
votes
1 answer
What does double splat (**) argument mean in this code example and why use it?
So I've been over Traiblazer and Reform documentation and I often see this kind of code
class AlbumForm < Reform::Form
collection :songs, populate_if_empty: :populate_songs! do
property :name
end
def populate_songs!(fragment:, **)
…

Dorian
- 2,571
- 23
- 33
3
votes
1 answer
Nested property fields do not show up using the Reform gem
I'm using the Reform gem to make a form object in my current project but the nested fields don't show up in the form. Here's my code:
Shipment Model:
class Shipment < ApplicationRecord
has_one :shipment_detail
end
ShipmentDetail Model:
class…

Ryan Angelo
- 93
- 1
- 13
3
votes
1 answer
Reform: Dry-Validation Matchers
I'm looking for a convenient way to test validations of a Reform-based form object.
Are there any matchers (like shoulda matchers for testing ActiveModel::Validations) to test dry-validations? Is this even the way to go?

Arvinje
- 328
- 2
- 16
3
votes
1 answer
Reform gem: use one model for multiple forms
I am using Reform gem to make a form object for checkout in my web store. I have the Checkout form which contains properties for Order model, which has associations with Address model.
Problem is the Order model has two association with the same…

VAD
- 2,351
- 4
- 20
- 32
3
votes
0 answers
Reform to wrap a collection of records to be saved simultaneously
I have a collection of records that are related to a specific parent object. I have no need to update the parent, just want to update all the children.
I tried making a Reform::Form and simply adding the collection declaration. An example might be…

Apie
- 6,371
- 7
- 27
- 25
2
votes
0 answers
uninitialized constant Reform::Form::Errors After update bundler and start rails server
After making the last update of my bundler by bundler update --system on my macOS Catalina last version update
I got this error
uninitialized constant Reform :: Form :: Errors
when I start my rails application server either by foreman s or rails s
I…

Houndjetode Noukpo Herve
- 151
- 2
- 13
2
votes
1 answer
Reform - Access parent form params inside of nested form scope
I'm using Reform 1.2.6 and have a nested form with validation
Simplified:
class UserForm < Reform::Form
property :date_of_birth
property health_profile do
property :diagnosed_with_condition_at
validate :diagnosed_date
def…

Petr Gazarov
- 3,602
- 2
- 20
- 37
2
votes
1 answer
How to translate model name and properties with Reform + dry-validations?
I'm in a project where I'm using the gem trailblazer(and by that, I'm using reform too) with dry-validations.
And kind of found how to translate error messages - I'm putting config.messages = :i18n inside each contract/reform class, since I didn't…

Kleber NG
- 107
- 1
- 6
2
votes
1 answer
undefined method `persisted?' with Reform and Virtus model
I'm currently developing an Rails app (rails v5.1.1 and ruby v2.3.4) and I'm getting an error when trying to use a reform form object at one of my routes (/bookings/new):
undefined method `persisted?' for #
I'm using a…

Igor_Marques
- 1,742
- 2
- 16
- 24
2
votes
1 answer
Undefined method `model_name` for reform object
I keep on getting:
Undefined method `model_name` for #
I'm pretty sure I'm missing something. I've followed the installation instruction and everything. What could be the reason?
Model:
class Donation <…

RubyCat
- 155
- 11
2
votes
0 answers
Trailblazer Rails form error "unknown keywords: doc, options, represented, decorator, binding, as, index, model, collection"
I'm using the trailblazer gem with Rails, and trying to get it to work with a form with nested models. So far, I'm only trying to adapt the create and update actions to use Operations. Updating pre-existing nested models works fine. Creating new…

neurodynamic
- 4,294
- 3
- 28
- 39