File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ public function configureFields(string $pageName): iterable
58
58
->setEmptyData ('' )
59
59
->hideOnIndex (),
60
60
AssociationField::new ('departments ' , new TM ('confirmer.departments ' ))
61
+ ->setFormTypeOption ('by_reference ' , false )
61
62
->autocomplete ()
62
63
63
64
];
Original file line number Diff line number Diff line change @@ -131,6 +131,28 @@ public function getDepartments(): Collection
131
131
return $ this ->departments ;
132
132
}
133
133
134
+ public function addDepartment (Department $ department ): Confirmer
135
+ {
136
+ if (!$ this ->departments ->contains ($ department )) {
137
+ $ this ->departments ->add ($ department );
138
+ if (!$ department ->getConfirmers ()->contains ($ this )) {
139
+ $ department ->getConfirmers ()->add ($ this );
140
+ }
141
+ }
142
+ return $ this ;
143
+ }
144
+
145
+ public function removeDepartment (Department $ department ): Confirmer
146
+ {
147
+ if ($ this ->departments ->contains ($ department )) {
148
+ $ this ->departments ->removeElement ($ department );
149
+ if ($ department ->getConfirmers ()->contains ($ this )) {
150
+ $ department ->getConfirmers ()->removeElement ($ this );
151
+ }
152
+ }
153
+ return $ this ;
154
+ }
155
+
134
156
public function __toString ()
135
157
{
136
158
return $ this ->name . ' ( ' . $ this ->email . ') ' ;
You can’t perform that action at this time.
0 commit comments