How do I control a split form?

Asked

Viewed 41 times

0

I have a system that has a lot of <input>necessary to assemble a requisition, they are divided into 4 parts (components), each part having one or more subparts (subcomponents)

I don’t want to save the data to the server gradually, the server will only receive a request with all the data. So I need to store it locally

I had two ideas:

  1. Create a template for each component and subcomponent and issue an event when it is completed that will be heard by the root component, there will be managed data

  2. Locally save data pads in Localstorage, when the last step is ready, mount the request

Remarks:

  • In model 1 the data will be saved locally anyway, but this will be done only by the root component, already in model 2 this will be done by each component or subcomponent

  • Because it is a very large form, it may not be fully completed in a single moment, just as it may be necessary to start a new registration, but keeping the previous one saved to finish later

How to make this control simple and readable? Other ways are welcome

Doubt is not how to implement, but which to implement

  • I wouldn’t use either of the two ways. I believe storing form data in localStorage is not a very sensible practice, as data can become vulnerable (with XSS mostly). Have searched for something called form Wizard?

  • @Luizfelipe why vulnerability to XSS attacks? Can not put a container form, it would be very difficult to control the children components through the father, besides if I create with the Formbuilder I would have a giant structure, difficult to understand and maintain

  • Suppose someone, for some reason, can inject a script into your system (XSS). They can access the localStorage from there. So I don’t think it’s a good practice...

  • But only if I allow the person ijete some script, if my system is protected, Localstorage is also

  • Indeed. But I still believe that options such as form Wizard be simpler. Have a look? :)

  • Yes, but it is a form not very simple and little readable

  • I think the best solution is to use something like ngrx to centralize the state of your form.

  • @Eduardovargas could add an answer?

  • Dude I find a little too complex to be a stackoverflow response. But think you have a store that is a centralized state and every step you update it.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.