Skip to content

How to Generate Dynamic Nested Fields Template Using Superform? #48

@danieldocki

Description

@danieldocki

When creating nested fields with Stimulus, I typically generate a template that can be dynamically appended to the view. With fields_for, I use a pattern like this:

fields_for "tasks[]", Task.new, index: "NEW_RECORD" do |task|
  task.text_field(:name)
end

which outputs:

<input type="text" name="tasks[NEW_RECORD][name]" id="tasks_NEW_RECORD_name">

Issue

I'm trying to achieve the same dynamic behavior with Superform, but I'm not sure how to generate the nested fields template to add new elements dynamically. Can anyone provide guidance on how to replicate this behavior with Superform?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions