- π¦πΊAustralia acbramley
Just ran into this codepath with paragraphs_library which ends up with the
add
operation on the add form (rather than default). This means that quite a few things don't happen in EntityTypeInfo::formAlter(), noteably for my case it was this little bit:if (isset($form['footer']) && in_array($form_object->getOperation(), ['edit', 'default'], TRUE)) { $form['moderation_state']['#group'] = 'footer'; }
Which was causing the moderation_state dropdown to be above the revision log field on the add screen but not the edit screen.
This is also inside an elseif which checks
isModeratedEntityEditForm
- that also checks the form operations but also includes layout_builder. - πΊπΈUnited States recrit
This bug also causes issues when adding translations that should be moderated.
Translation bug for "add" form operation:- Contrib module or custom code adds a node form class for "add".
- Adding a translation: The "\Drupal\content_translation\Controller\ContentTranslationController::add()" uses the following code to to set the form operation to "add".
$operation = $entity->getEntityType()->hasHandlerClass('form', 'add') ? 'add' : 'default';
- Entity Prepare Form:
\Drupal\content_moderation\EntityTypeInfo::entityPrepareForm()
usesEntityTypeInfo::isModeratedEntityEditForm()
to alter the form to add a redirect. The "add" form mode is not detected by "isModeratedEntityEditForm".
RESULT: The new revision is not created correctly leaving the entity's "revision_translation_affected" set to TRUE. This causes all sort of revisioning issues such as "revision_translation_affected" set to TRUE for the source translation's revision that is linked to the new language translation. - Form altering:
\Drupal\content_moderation\EntityTypeInfo::formAlter()
usesEntityTypeInfo::isModeratedEntityEditForm()
to alter the form to add a redirect. RESULT: Redirect to the latest-version is not set since "add" is not listed in "isModeratedEntityEditForm"
Proposed Resolution
Add "add" to the form operation list in
\Drupal\content_moderation\EntityTypeInfo::isModeratedEntityEditForm()
.
This is not ideal but a similar patch has been already added to "isModeratedEntityEditForm()" for "layout_builder". - π¬π§United Kingdom kimberleycgm
I've also run into this problem and agree it should be configurable in some way, but open to suggestions on the best way. A `hook_entity_type_info_edit_form_modes_alter` perhaps, or it being defined as part of the form mode. I'm happy to get started on a solution.