I found a work around solution:
1.)
Create a second field that is used as a helper only. This is needed because nuBuilder does not allow to have two edit fields that are linked to the same column and have the same ID.
I added dpl_prj_dml_items_select.
2.)
Create a hidden textfield for the real value
eg: dpl_prj_dml_items
Create a visible select that shall be synced with the textfield value and is linked to the newly created DB column.
eg: dpl_prj_dml_items_select
3.)
Add this code to the form's JavaScript section:
Code: Select all
$('#dpl_prj_dml_items_select').val(JSON.parse($('#dpl_prj_dml_items').val()));
This updates the select on item load.
4.)
Add this code to the Lookup object's JavaScript section:
Code: Select all
$('#dpl_prj_dml_items_select').val(JSON.parse($('#dpl_prj_dml_items').val()));
The lookup shall update the value of dpl_prj_dml_items in the After Browse PHP code and afterwards the dpl_prj_dml_items_select is updated with js.
5.)
In dpl_prj_dml_items_select add the following custom code:
onchange
Code: Select all
$('#dpl_prj_dml_items').val('[\"'+$('#dpl_prj_dml_items_select').val().join('\",\"')+'\"]');$('#dpl_prj_dml_items').trigger("change");
This converts back to a string and sets the hidden dpl_prj_dml_items when the select was changed and clicked.
I currently haven't found a more elegant solution without this string handling but it works well.
6.) (optional)
It seems that the SQL DB column can be removed again. The data itself is redundant and has no value.