My code is for a checkbox group whose multiple options selected in the form should be posted in a comma separated text format into one field marked varchar with enough room to store all options if selected.
If I use a dropdown list with a dynamic table source and the code is marked for multiple=“true” I get exactly the comma-separated insert behavior with no extra configuration required. A regular wappler insert query requires nothing special.
But this checkbox set up the same way with a repeating dynamic options source (as my dropdown list form) requires extra steps. Right now I only get the last option’s text inserted into the table input.
Yet, the code, though not styled yet, shows the dynamic sourced values as the checkboxes as I want.
The answer must be staring me in the face.
When I use Developers tools Inspect the code Request shows each value selected but split into separate inserts with the same input name, instead of just one input name with all the values together separated by commas.
I have tried that before but I am getting ERROR “Array to string conversion”
"#0 [internal function]: exception_error_handler(8, 'Array to string...', '/is/htdocs/wp12...', 139, Array)\n#1 /is/htdocs/wp12516289_VXRU2NWLJ9/www/myweburl.de/dmxConnectLib/lib/db/Connection.php(139): PDOStatement->bindParam(7, Array, 2)\n#2 /is/htdocs/wp12516289_VXRU2NWLJ9/www/myweburl.de.de/dmxConnectLib/modules/dbupdater.php(38): lib\\db\\Connection->execute('INSERT INTO `st...', Array, false
I think I really have to fix this in my INSERT server parameters for this table input “gefuehl_1”
The problem is in the internal looping repeat – the input name gets repeated over & over. name="gefuehl_1[]" should only happen once, not multiple times itself.
Here is the code that works perfectly when I “simply” set up a List selector. It allows multiple lines/options to be selected. I believe @Teodor supplied this months ago
The input box below immediately confirms the 3 selections. However, this requires using a key to be depressed as the mouse moves for each selection.
Not as user-friendly as a simple multiple checkbox group only needing a mouse.
This is the code for the List selector view – I just can’t get this code re-written to achieve the same comma-separated multiple text string as the list selector.
Method 2 as teodor said using a name on the checkboxes like check[]
Then if you use $_POST.check.join(',') on the insert/update it will input a comma seperated array
I’ve posted now several times why the brackets (which is how I always processed multiple choice checkboxes for the past couple of decades) will not work.
The way that method works is if the checkbox group is hard-coded.
Using the looping method I have been using just never will hold the array of selected values cumulatively.
Trust me.
I am going to have to abandon this whole thing and go back to hard-code.