formtools / core

The Form Tools Core.
https://formtools.org
207 stars 78 forks source link

Uncaught PDOException: SQLSTATE[23000] when adding new external form (step 5) #597

Open flcowboy7 opened 5 years ago

flcowboy7 commented 5 years ago

I'm getting this error on Step 5 (field types) of adding an external form, which has a LOT of form fields. I'm not sure what to do at this point. Any ideas @benkeen ?

Error: Invalid JSON:
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1553-11' for key 'PRIMARY' in /home/{user}/public_html/formtools/global/code/Database.class.php:157

Stack trace:
#0 /home/{user}/public_html/formtools/global/code/Database.class.php(157): PDOStatement->execute()
#1 /home/{user}/public_html/formtools/global/code/FieldSettings.class.php(43): FormTools\Database->execute()
#2 /home/{user}/public_html/formtools/global/code/Forms.class.php(1113): FormTools\FieldSettings::addSetting(1553, 11, 115)
#3 /home/{user}/public_html/formtools/global/code/actions.php(232): FormTools\Forms::setFormFieldTypes('42', Array)
#4 {main} thrown in /home/{user}/public_html/formtools/global/code/Database.class.php on line 157
flcowboy7 commented 5 years ago

If I'm reading the code right, this is happening because this form has 15 sections of duplicated form fields. In other words, there are 15 form fields with an identical option list set. The error is only stopping at the first duplicated option list, but there will be more. Each form field is using a unique id="" and name="" in the HTML.

Example: Form Field 1 = apples, oranges Form Field 2 = apples, oranges Form Field 3 = apples, oranges etc, etc.

Normally, after creating the form, I would configure it so that each duplicated field uses only one master option list and I would delete the duplicated option lists. But I don't believe that's an option during the creation process.

I've tried "skipping" this step, but there are 193 total fields in this form (don't even ask), so I will need to change most of them to LARGE, which I have to do in this step to avoid the "SQL Error: SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large." error from happening.

I then tried to remove all of the duplicate form fields from the form, thinking I could add them back later. Unfortunately, FT remembered that I had already tried to create the form with 193 fields and wouldn't let me proceed without showing me the same error (from my OP) again.

Then I tried deleting the actual option lists and trying to complete the form creation again. no dice. It created the option list with a new ID# and then threw the same error again.

Next, I went in and "resent the test submission." This time, only filling in the fields in the first sub-section (so there wouldn't be duplicate option lists, yet). That didn't work, because it found all the fields, even though i didn't manually enter values in them all this time (which was a PAIN the first time).

I did the same thing again (resend test submission), but tried deleting all the extra fields before getting to step 5. FINALLY! Now I have a form that can be configured. I just have to manually add all those other fields back. :(

flcowboy7 commented 5 years ago

This process is working, where I had to delete all the duplicate fields during the form creation process and then manually re-add them in the FT interface after the form was added. It's proving to be a major PITA with this many form fields, but it IS working.