Open dhnaranjo opened 8 months ago
It looks like the collection
method is passing a NamespaceCollection constant into the create_child
method, which doesn't pass the reference to the class you've extended.
Here's the code that I think has the bug: https://github.com/rubymonolith/superform/blob/150985cc28a3d4888c12ea7c5b5109635d9d4870/lib/superform.rb#L140-L144
module NamespacePatch
def collection(key, &)
create_child(key, Superform::NamespaceCollection, field_class: @field_class, &)
end
end
module NamespaceCollectionPatch
def initialize(*, field_class:, **, &)
@field_class = field_class
super(*, **, &)
end
def build_namespace(index, **)
parent.class.new(index, parent: self, field_class: @field_class, **, &@template)
end
end
This gets it where it needs to be. Want a PR?
Want a PR?
Heck yeah!
The call to
field(:id)
returns an instance ofApplicationForm::Field
, while the one inside the collection returnsSuperform::Field
, soinput
and all my custom fields are unavailable.My stupid hack is to monkeypatch
Superform::Namespace
.You got a better idea of how to handle this?