Hi
Im trying to use Select2 widget to dynamically choose either a client or a vendor from 2 different tables (client or vendor). As the ids between tables may not be distinct i need to make them unique by prefixing a value before the id. I prefix the key with client-<rowId> or vendor-<rowId>. I then use the prefix to determine if they have selected a client or vendor, remove the prefix to get the id and link it accordingly. This all works fine and the linkage is created to the correct table using the LinkAll plugin.
However when i try to update the item the already chosen client or vendor does not appear in the dropdown unless the attribute key and value are identical i.e.
Start your code here
Array ( [vendor-vendorName] => vendor-vendorName) // Works
Array ( [vendor-vendorName] => vendorName ) // Doesnt Work
Array ( [vendor-1234] => vendorName ) // Doesnt Work
Is there any stipulation the key and value have to equal each other and if so why? The tutorial i am using as a reference is https://mrphp.com.au/blog/many-many-select2-yii2/
The post Select2 Key value names need to be the same? appeared first on Krajee Web Tips.