kaleem Posted April 11, 2022 Share Posted April 11, 2022 Hi All, i have a form with around 20 to 30 fields, some of these fields are file upload (file uploads are done as name in DB and file in folder and not as BASE64 or blob. i need to achieve following; 1 : let users submit part of form and comeback to fill rest (users will have login & pwd to come back) 2: know what fields are complete and which ones arent so show them incomplete only to fill if there are any tools / form builders which can help achieve these. thanks for your advise Quote Link to comment https://forums.phpfreaks.com/topic/314690-ideas-form-with-loads-of-fields/ Share on other sites More sharing options...
ginerjm Posted April 11, 2022 Share Posted April 11, 2022 If you are putting this input into a table you could add a key field to connect it to some token that is related to the page that shows the form. User does some entry, submits it, you grab it and if it is incomplete you save the data and your key values and create a cookie to hold those key values so that when your form is called up again the cookie that your script looks at tells it where to get the provided data and places it on the form. Once the input is complete you can delete the cookie and remove the key values from the db record. If the data is not going to a table then you will have to make a table to hold it temporarily. Quote Link to comment https://forums.phpfreaks.com/topic/314690-ideas-form-with-loads-of-fields/#findComment-1595248 Share on other sites More sharing options...
kaleem Posted April 11, 2022 Author Share Posted April 11, 2022 thanks Ginerjm, data will be goinginto DB. also, i wanted to know if there is way to autosave fields when focus is lost as user might navigateaway and we dont want to miss data half way thru due to any issue. Quote Link to comment https://forums.phpfreaks.com/topic/314690-ideas-form-with-loads-of-fields/#findComment-1595250 Share on other sites More sharing options...
mac_gyver Posted April 11, 2022 Share Posted April 11, 2022 the form definition (each field's - id, label, type, name, placeholder text, choices/options, required attribute, validation attributes, ...) needs to be stored in a data structure (database table or array) and to allow for multiple different forms, the data structure should hold multiple definitions, each one receiving a unique id (auto-increment primary index.) the logged in user would then select which form definition to fill in, or if only one definition, be presented with that form. to save each field's entered/selected/checked value, you would need to use ajax to submit the data to the server. the storage of the data on the server would be similar to a database based shopping cart/ordering system, where you would have a table holding the unique/one-time information about the instances of a form being filled out with - an id, the user_id, the form_id (from the defining structure), datetime, status, ... this establishes a form_instance_id. you would use this id to store the submitted form field data in a second table with - an id, form_instance_id, form_field_id, value, ... when the visitor returns to the site and logs in, you would query the data to find if there are any form(s) in progress (the status column would be a value other than the one that corresponds to 'complete'.) you would give the user the choice of picking from among the incomplete form(s) or starting a new instance of a form. if they pick an incomplete form, you would query for the existing data values to re-populate the fields with. when you output the form, you would set the focus to the field after the last submitted value, i.e. the next form_field_id after that in the last row in the table holding the submitted data. Quote Link to comment https://forums.phpfreaks.com/topic/314690-ideas-form-with-loads-of-fields/#findComment-1595251 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.