within the options-array the name of the select2 needs to be of the format:
‘name’ => ‘MODEL[ATTRIBUTE]’
Then it works and also stores the id while displaying the text.
BUT: after further dev with the select2 I now face the problem, that this works very well on CREATE, but not on UPDATE:
On UPDATE I would then need to initialise the select2 which needs to retrieve the text.
Select2 comes with a handy ‘initSelection’ part, where you can call another ajax to retrive the text for the id. But this is only called, if there is a value given to the element by load. And exactly this is not the case. I do see the value on the VIEW, but when I click on the UPDATE, I can see in FireBug that the hidden field does not contain any value. All other non-select2 fields work fine.
(Yeah, I hear it already: Hey you found out the last question yourself: Repeat it!)