diff --git a/modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module b/modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module index 801b698871a..f645b0948ce 100644 --- a/modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module +++ b/modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module @@ -104,6 +104,12 @@ function social_event_max_enroll_form_alter(&$form, FormStateInterface $form_sta ], ]; + // Hide all `Enrollment limit` wrapper + // if event enrollment is disabled for event. + if (!$form['field_event_max_enroll']['#access'] && !$form['field_event_max_enroll_num']['#access']) { + $form['field_event_max_enroll_wrapper']['#access'] = FALSE; + } + $form['field_event_max_enroll_wrapper']['field_event_max_enroll'] = $form['field_event_max_enroll']; $form['field_event_max_enroll_wrapper']['field_event_max_enroll_num'] = $form['field_event_max_enroll_num']; unset($form['field_event_max_enroll'], $form['field_event_max_enroll_num']);