Home > Blockchain >  Django Form so many fields
Django Form so many fields

Time:10-30

I have a Django page using bootstrap and crispy forms that present a form. but the form is growing so much now that I probably have around 50 fields :( which are all within 1 massive HTML page. I'm pretty sure this is the wrong way to do it.

Is it possible to split the forms into say 5 pages, but still have a submit button to post all of the fields to the database?

For now, what I have done is to create tabs for each section of the giant form so it's easy than scrolling.

I'm thinking it's probably better to create different views for each section and then link the data somehow back using an IndexKey or something?

But i have no idea how i would configure the button to capture all the fields.

I know this is a rubbish question, but I don't really know what to search for?

Cheers

CodePudding user response:

You can try to divide the form in bootstrap tabs like Personal information --> form fields Additional information --> form fields

CodePudding user response:

Why don't you break the data input down into as many questions as you think is appropriate for each page? If you have 50 inputs, you could do 10 over 5 pages.

After submitting Page 1, return the POST data to Page 2 and store the data in hidden input fields. Repeat the process until Page 5 when you can POST all 50 to the server and insert the data into your Database.

  • Related