PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 6, 2022

[FIXED] Multi-Select template for custom forms

 February 06, 2022     easyadmin3, php, symfony     No comments   

Issue

In my EasyAdmin 3 application I have build a custom form (with Symfony and Doctrine) with a multi-select field. Since it is a custom form I do not get the nice multi-select dropdown theme that EasyAdmin normally provides:

enter image description here

With earlier EasyAdmin versions it was possible to just add the "select2" classes to the field. But it seems to work different now in EasyAdmin 3. Is there a way to add the multi-select theme of EasyAdmin to a custom form field?

My use case is: I have an AccountEntity which has a relation to a UserEntity and a ServiceEntity. I want to have the possibility to add multiple Accounts for a User with different Services. Since an Account has only one Service I can not use the standard Account Creation Form. I need the Service field to be a multi-select. So my current idea is to built a custom form with Symfony and Doctrine and have my own logic to create the Accounts. Maybe there is a better way to build this functionality with built-in features of EasyAdmin 3?


Solution

Actually I found the answer to my problem:

You have to add the following attribute to the form field:

data-ea-widget="ea-autocomplete"

Also EasyAdmin3 is using https://tom-select.js.org/ instead of Select2 like in the previous versions.



Answered By - kcm
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing