Loading scheduler_content_moderation_integration.module +2 −9 Original line number Diff line number Diff line Loading @@ -140,21 +140,14 @@ function scheduler_content_moderation_integration_form_node_form_alter(&$form, F */ function _scheduler_content_moderation_integration_hide_empty_state_options(array $element, FormStateInterface $form_state) { foreach (Element::getVisibleChildren($element) as $key) { // Hide the element if there are no options. if (empty($element[$key]['#options'])) { $element[$key]['#access'] = FALSE; } else { $options_without_none = array_filter($element[$key]['#options'], function ($option) { return $option != '_none'; }, ARRAY_FILTER_USE_KEY); // Hide the element if the only option is 'none'. $options_without_none = array_diff_key($element[$key]['#options'], ['_none' => '']); $element[$key]['#access'] = (bool) count($options_without_none); // If there is only one option apart from 'none' then remove 'none'. if (count($options_without_none) === 1) { $element[$key]['#value'] = key($options_without_none); $element[$key]['#options'] = $options_without_none; } } } return $element; Loading Loading
scheduler_content_moderation_integration.module +2 −9 Original line number Diff line number Diff line Loading @@ -140,21 +140,14 @@ function scheduler_content_moderation_integration_form_node_form_alter(&$form, F */ function _scheduler_content_moderation_integration_hide_empty_state_options(array $element, FormStateInterface $form_state) { foreach (Element::getVisibleChildren($element) as $key) { // Hide the element if there are no options. if (empty($element[$key]['#options'])) { $element[$key]['#access'] = FALSE; } else { $options_without_none = array_filter($element[$key]['#options'], function ($option) { return $option != '_none'; }, ARRAY_FILTER_USE_KEY); // Hide the element if the only option is 'none'. $options_without_none = array_diff_key($element[$key]['#options'], ['_none' => '']); $element[$key]['#access'] = (bool) count($options_without_none); // If there is only one option apart from 'none' then remove 'none'. if (count($options_without_none) === 1) { $element[$key]['#value'] = key($options_without_none); $element[$key]['#options'] = $options_without_none; } } } return $element; Loading