Issue 3457663: using variable scheduler group array key
The scheduler group name defined in the scheduler module is variable, adding a numerical suffix to cope for situations where more than one entities exist in the form. Copying the corresponding code snippet from scheduler.module below:
// Create the group for the fields. The array key has to be distinct when more
// than one $entity appears in the form, for example in Media Library uploads.
// Keep the first key the same as before, without any suffix, as this is used
// in drupal.behaviors javascript and could be used by third-party modules.
static $group_number;
$group_number += 1;
$scheduler_field_group = ($group_number == 1) ? 'scheduler_settings' : "scheduler_settings_{$group_number}";
$form[$scheduler_field_group] = [
'#type' => 'details',
'#title' => t('Scheduling options'),
'#open' => $expand_details,
'#weight' => 35,
'#attributes' => ['class' => ['scheduler-form']],
'#optional' => FALSE,
];
// Attach the fields to group.
$form['publish_on']['#group'] = $form['unpublish_on']['#group'] = $scheduler_field_group;`
From the other hand scheduler_content_moderation_integration
assumes that the scheduler
group name remains the same (i.e. scheduler_settings
). Thus when this changes the publish_state
and upublish_stage
fields are added in a group that doesn't exist.
This PR follows the same approach as the scheduler module to fix this issue.