trailblazer / reform

Form objects decoupled from models.
https://trailblazer.to/2.1/docs/reform.html
MIT License
2.49k stars 184 forks source link

Dynamic form fields and stack level too deep #510

Closed dwkoogt closed 4 years ago

dwkoogt commented 4 years ago

Hi, I've had something similar to #291 (Dynamic form fields) working fine for Rails 4.2 with following gems: reform 2.2.3 reform-rails 0.1.7 disposable 0.3.2

Now, I'm trying to upgrade to Rails 5.2 and I've updated the gems to: reform 2.3.1 reform-rails 0.2.0 disposable 0.4.7

But I'm getting the stack level too deep errors on validation (#261).

Any ideas how I can resolve this issue?

Issue references: #291 and #261

dwkoogt commented 4 years ago

It seems like it's breaking at validator.valid? call within call method in reform/form/active_model/validation (this is in reform-rails actually).

I tried reform 2.2.4 and it would break at valid? call within validate! method in reform/contract/validate.

It does work if i do a simple test in the console though. Also, I can do a custom validation instead and get around this issue.

samstickland commented 3 years ago

@dwkoogt How did you get dynamic form fields working? I'm just about to tackle some similar requirements so I'd be interested in knowing what you did.

apotonick commented 3 years ago

Yes @dwkoogt a quick example of your dynamic form (I guess you're defining anonymous classes) would be great. Your error somehow rings a bell but I can't remember what was the exact problem.