Slide 1

Slide 1 text

/ 29 Symfony UX Autocomplete 
 2 023 / 06 / 2 7 #PHPTechCafe @ttskch 1

Slide 2

Slide 2 text

Kannade PHP 11 Zenn Symfony 
 @ttskch

Slide 3

Slide 3 text

/ 29 symfony/form 3 FormType ⾒ TextType TextareaType ChoiceType EntityType 


Slide 4

Slide 4 text

/ 29 DB EntityType 4

Slide 5

Slide 5 text

/ 29 $builder ->add('user', EntityType::class, [ 'class' => User::class, 'placeholder' => 'બ୒͍ͯͩ͘͠͞', ]) ; 5 EntityType

Slide 6

Slide 6 text

/ 29 EntityType 6

Slide 7

Slide 7 text

/ 29 EntityType 7

Slide 8

Slide 8 text

/ 29 EntityType N+ 1 8 __toString() ⾒ N+ 1

Slide 9

Slide 9 text

/ 29 class User { // ... public function __toString(): string { return sprintf('%s %s', $this->team, $this->name); } } 9 EntityType N+ 1

Slide 10

Slide 10 text

/ 29 EntityType N+ 1 10

Slide 11

Slide 11 text

/ 29 EntityType N+ 1 11 User

Slide 12

Slide 12 text

/ 29 Doctrine 
 Doctrine JOIN 
 EntityType N+ 1 12

Slide 13

Slide 13 text

/ 29 13 EntityType JOIN

Slide 14

Slide 14 text

/ 29 $builder ->add('user', EntityType::class, [ 'class' => User::class, 'placeholder' => 'બ୒͍ͯͩ͘͠͞', 'query_builder' => function (UserRepository $repository) { return $repository->createQueryBuilder('u') ->leftJoin('u.team', 't') ->addSelect('t') ; }, ]) ; 14

Slide 15

Slide 15 text

/ 29 15 1 🙆

Slide 16

Slide 16 text

/ 29 16 N+ 1 Select 2 selectize.js JavaScript 
 ⾒ 


Slide 17

Slide 17 text

/ 29 17 Symfony UX Autocomplete

Slide 18

Slide 18 text

/ 29 Symfony UX 18 PHP JavaScript Symfony UI

Slide 19

Slide 19 text

/ 29 Symfony UX Autocomplete 19 Symfony UX 1 EntityType ChoiceType 


Slide 20

Slide 20 text

/ 29 Symfony UX Autocomplete 20 Symfony UX 1 EntityType ChoiceType 


Slide 21

Slide 21 text

/ 29 #[AsEntityAutocompleteField] class UserAutocompleteField extends AbstractType { public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'class' => User::class, 'placeholder' => 'ݕࡧ͍ͯͩ͘͠͞', ]); } public function getParent(): string { return ParentEntityAutocompleteType::class; } } 21 🙏 FormType

Slide 22

Slide 22 text

/ 29 $builder ->add('user', UserAutocompleteField::class) ; 22 🙏 🙆

Slide 23

Slide 23 text

/ 29 23 💡

Slide 24

Slide 24 text

/ 29 24

Slide 25

Slide 25 text

/ 29 25 User API Symfony UX Autocomplete 
 API

Slide 26

Slide 26 text

/ 29 26 JavaScript Tom Select Tom Select FormType ⾒ JavaScript 
 Tom Select 
 🙏

Slide 27

Slide 27 text

/ 29 27 Symfony UX Autocomplete Symfony UI 
 N+ 1 Autocomplete 
 N+ 1 10 


Slide 28

Slide 28 text

/ 29 🐙 28 https://github.com/ ttskch/symfony-ux-autocomplete-example

Slide 29

Slide 29 text

/ 29 29 Thanks! @ttskch