Skip to content

Support Nested Forms (Forms in Forms)#849

Closed
CurtisHumphrey wants to merge 1 commit intorjsf-team:masterfrom
CurtisHumphrey:master
Closed

Support Nested Forms (Forms in Forms)#849
CurtisHumphrey wants to merge 1 commit intorjsf-team:masterfrom
CurtisHumphrey:master

Conversation

@CurtisHumphrey
Copy link

Reasons for making this change

This allows nested forms because a form in a form is bad DOM

Use case:

  • A form that has an link new record button that creates a new form (nested) that allow one to create this new record and then returns the record id to the first form for linking. In my case the record is an uploaded picture.

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@CurtisHumphrey
Copy link
Author

Ok, I'll fix those errors here in the next day or so.

@glasserc
Copy link
Contributor

glasserc commented Mar 7, 2018

I don't really understand your use case, but even if a form within a form is bad, then certainly a form by itself should still be a <form>, no?

@edi9999
Copy link
Collaborator

edi9999 commented Apr 5, 2018

Can you describe your usecase @CurtisHumphrey ?

This seems like it could be closed.

@olzraiti
Copy link
Contributor

I have actually exactly the same use case. Our images are uploaded to a separate database, and only the image ID is saved to the document. I display a RJSF for updating the metadata for the images, so we have two nested <form> elements (well, I actually don't since I solved this by displaying the image form in a modal, that is rendered outside the parent RJSF element).

Maybe we could render a <form> by default, but allow some parameter for changing the element type for special use cases like this?

@edi9999
Copy link
Collaborator

edi9999 commented Apr 12, 2018

I think you should be having a json-schema that has multiple levels instead of trying to have Forms and subforms.

Seee for example the "Nested" demo in https://mozilla-services.github.io/react-jsonschema-form/

@olzraiti
Copy link
Contributor

olzraiti commented Apr 12, 2018

In the use case described here, the image meta data document is saved independently from the parent document, and the parent document contains only a reference ID to the image. So we can't just add the image schema as a property to the parent schema, because we want to save only the ID - not the whole image metadata document - to the parent document.

@CurtisHumphrey
Copy link
Author

I've re-put this on my list of ToDos for next week. Sorry for the delays.

@epicfaace
Copy link
Member

@CurtisHumphrey , I'm closing this PR -- if we were to implement this, it should definitely by default render a <form> tag and only have the option to render another HTML tag instead. That issue is tracked in #71.

@epicfaace epicfaace closed this Jan 19, 2019
@epicfaace
Copy link
Member

This was fixed by #1345!

@epicfaace epicfaace reopened this Aug 11, 2019
@epicfaace epicfaace closed this Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants