Allow to adapt TomSelect selects via setFormTypeOptions method
Short description of what this feature will allow to do: Right now there seems to be no possibility to modify the TomSelect behaviour trough PHP definitions, one must re-initialize TomSelect selects in a very complex way by injecting custom JS into a CRUD controller, then modifying TomSelect to your needs.
This is obviously a bit bad.
Example of how to use this feature
yield AssociationField::new('groups', t('Group'))
->setColumns('col-sm-12')
->setFormTypeOptions([
'attr' => [
'data-tomselect-options' => json_encode([
'placeholder' => 'Select an option',
'maxItems' => 1,
'allowEmptyOption' => true,
])
],
])
This way, I could specify the form to allow one one selection, regardless of its Assignment. In the frontend, the user then would be able to select only one element.
This is useful when you have a complex relation between elements.
For example in my case, I have a Task, that is a ManyToMany relation to Groups, which is owned by a User (in a OneToMany relation).
So: Many Tasks have Many groups, which individually belong to one User.
In this case, EasyAdmin can only cover the first relation, with no possibility to have the second constraint in mind. By allowing a developer to form the select himself, it will be easier to cover complex relationship scenarios.
This issue has been inactive for 3 months. It will be closed in 5 days unless there is new activity.
Check if this is still relevant (maybe it was already fixed by some PR) and leave a comment or update the issue with any new information.
Thanks for reporting this.
We are closing this issue because it has had no activity for the last 3 months. This helps us keep the tracker manageable and focus on actively discussed work.
If this is still relevant, please reopen the issue (or open a new one) with updated information, and any logs or stack traces you can share.