class PageForm < ApplicationForm
def template
div do
field(:id).input
collection(:responses).each do |response_fields|
response_fields.field(:option_id).input
end
end
end
end
The call to field(:id) returns an instance of ApplicationForm::Field, while the one inside the collection returns Superform::Field, so input and all my custom fields are unavailable.
My stupid hack is to monkeypatch Superform::Namespace.
module Superform
class Namespace < Node
def initialize(key, parent:, object: nil, field_class: ApplicationForm::Field)
super(key, parent:)
@object = object
@field_class = field_class
@children = {}
yield self if block_given?
end
end
end
You got a better idea of how to handle this?