@@ -61,3 +61,77 @@ design:
6161 - '@EasyAdmin/form/bootstrap_4.html.twig'
6262 - '@FMElfinder/Form/elfinder_widget.html.twig'
6363` ` `
64+
65+ # # EasyAdmin 3.x/4.x integration
66+
67+ Almost same as for 2.x, but you need to add
68+
69+ ` ` ` php
70+
71+ // ProjectCrudController.php
72+ // ...
73+ public function configureFields(string $pageName): iterable
74+ {
75+ // ...
76+ yield Field::new('image', 'Image')
77+ ->setFormType(ElFinderType::class)
78+ ->setFormTypeOptions([
79+ 'instance' => 'default',
80+ 'enable' => true,
81+ ])
82+ ->onlyOnForms()
83+ ;
84+ // ...
85+ }
86+
87+ public function configureCrud(Crud $crud): Crud
88+ {
89+ return $crud
90+ // ...
91+ ->addFormTheme('@FMElfinder/Form/elfinder_widget.html.twig')
92+ ;
93+ }
94+ ` ` `
95+
96+ Collection field :
97+ ` ` ` php
98+ return [
99+ Field::new('cover', 'Cover')->setFormType(ElFinderType::class)
100+ ->setFormTypeOptions(
101+ [
102+ 'instance' => 'image_form',
103+ 'attr' => ['class' => 'col-6'],
104+ ]
105+ )
106+ ->hideOnIndex(),
107+ CollectionField::new('photos', 'Photos')
108+ ->setEntryType(PhotoType::class)
109+ ];
110+ ` ` `
111+
112+ ` ` ` php
113+ public function buildForm(FormBuilderInterface $builder, array $options)
114+ {
115+ $builder
116+ ->add('path', ElFinderType::class, [
117+ 'instance' => 'image_form',
118+ 'enable' => true
119+ ])
120+ ->add('translations', TranslationsType::class, [
121+ 'fields' => [
122+ 'description' => [
123+ 'field_type' => CKEditorType::class,
124+ 'label' => 'Description',
125+ ],
126+ ],
127+ ]);
128+ }
129+ ` ` `
130+
131+ And override elfidner_widget.html.twig
132+ ` ` ` js
133+ live('click', '[data-type="elfinder-input-field"]', function (event) {
134+ var id = $(this).attr('id');
135+ var childWin = window.open("{{path('elfinder', {'instance': instance, 'homeFolder': homeFolder })}}?id="+id, "popupWindow", "height=450, width=900");
136+ });
137+ ` ` `
0 commit comments