@@ -274,7 +274,15 @@ public static function processIdentityElement(array &$element, FormStateInterfac
274
274
],
275
275
];
276
276
277
- $ element ['entities ' ]['for_bundle ' ] = [
277
+ $ element ['entities ' ]['controls ' ] = [
278
+ '#type ' => 'container ' ,
279
+ '#tree ' => TRUE ,
280
+ '#attributes ' => [
281
+ 'class ' => ['person-controls ' ],
282
+ ],
283
+ ];
284
+
285
+ $ element ['entities ' ]['controls ' ]['for_bundle ' ] = [
278
286
'#type ' => 'radios ' ,
279
287
'#title ' => t ('Person type ' ),
280
288
'#options ' => $ for_bundles ,
@@ -294,8 +302,33 @@ public static function processIdentityElement(array &$element, FormStateInterfac
294
302
'#attributes ' => [
295
303
'class ' => ['person-type ' ],
296
304
],
305
+ '#parents ' => array_merge ($ parents , ['entities ' , 'for_bundle ' ]),
297
306
];
298
307
308
+ $ element ['entities ' ]['controls ' ]['actions ' ] = [
309
+ '#type ' => 'actions ' ,
310
+ '#tree ' => TRUE ,
311
+ ];
312
+
313
+ // Display a close button if there are people and arity is multiple.
314
+ if ($ arity_is_multiple && count ($ people ) > 0 ) {
315
+ $ element ['entities ' ]['controls ' ]['actions ' ]['done ' ] = [
316
+ '#type ' => 'submit ' ,
317
+ '#value ' => t ('Done ' ),
318
+ '#ajax ' => [
319
+ 'callback ' => [static ::class, 'ajaxElementRoot ' ],
320
+ 'wrapper ' => $ ajax_wrapper_id_root ,
321
+ ],
322
+ '#limit_validation_errors ' => [],
323
+ '#validate ' => [
324
+ [static ::class, 'decoyValidator ' ],
325
+ ],
326
+ '#submit ' => [
327
+ [static ::class, 'submitClose ' ],
328
+ ],
329
+ ];
330
+ }
331
+
299
332
$ element ['entities ' ]['person ' ] = [
300
333
'#type ' => 'container ' ,
301
334
'#tree ' => TRUE ,
@@ -801,6 +834,24 @@ public static function submitChangeDefault(array $form, FormStateInterface $form
801
834
}
802
835
}
803
836
837
+ /**
838
+ * Submission callback to close the selection interface.
839
+ *
840
+ * @param array $form
841
+ * The complete form.
842
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
843
+ * The current state of the form.
844
+ */
845
+ public static function submitClose (array $ form , FormStateInterface $ form_state ) {
846
+ $ form_state ->setRebuild ();
847
+
848
+ $ element = RegistrantsElement::findElement ($ form , $ form_state );
849
+ $ utility = new RegistrantsElement ($ element , $ form_state );
850
+
851
+ $ utility ->setChangeIt (FALSE );
852
+ $ utility ->clearPeopleFormInput ();
853
+ }
854
+
804
855
/**
805
856
* For_arity radios submission handler.
806
857
*
0 commit comments