PHP: How to make dataprocessor to work with multiselect?


#1

How to make dataprocessor to work with multiselect? Is it possible? I have loaded options in multiselect, but unable to load selected values.
I have many-to-many relation table, with two fields as primary key. In other words - “Item” have a “Category” or few.

>     var categoryForm = categoryWin.attachForm(
>       [{
>         type:"multiselect",
>         connector: "data/tests.categories.php",//-this working fine
>         name: "category",
>       }]
>     ...
>     var dp3 = new dataProcessor("data/tests.category.form.php?id="+myForm.getItemValue('id'))
>     dp3.init(categoryForm);
>     ...
>     This loads one selected value, when there are definitely two must be:
>     //categoryForm.load("data/tests.category.form.php?id="+myForm.getItemValue('id'));
>     ...
>     PHP file:
>     <?php
>     require_once('../dx/connector/form_connector.php');
>     require_once 'common.inc.php';
>     $form = new FormConnector($conn);
>     $form->render_table("tests_category","test","category");
>     ...
>     MySql: 
>     CREATE TABLE `tests_category` (
>       `test` int(11) NOT NULL,
>       `category` int(11) NOT NULL
>     ) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
>     ALTER TABLE `tests_category`
>       ADD PRIMARY KEY (`test`,`category`);

#2

Hello
you need to use an individual connector object for loading the options for your multiselect (select options connector)
https://docs.dhtmlx.com/connector__php__selectoptionsconnector.html
while the dataprocessor should be attached to the dhtmlxForm, not the multiselect and connected to the connector that loads the data to your form fields.


#3

I have try that, and working fine partially - load options. Problem in selected options, I can’t load that, example not shows how, and not find the documentation about php. Example loads only value-label, not selected attribute.


#4

Where I should load “selected” or “checked” in this connector?


#5

Your form saves only the values of the selected options of your multiselect
http://snippet.dhtmlx.com/a15a82e2a
selectOptions connector only can load all the options to your multiselect. selected options are defined as values in your form connector