0

When I edit the layout for a given node it is missing a log message field in the revision area. Is anybody else seeing this or am I alone? In trying to diagnose:

  • Where that particular revision log field would be defined to check if it's defined at all. If it's not then this is probably a core bug that should be addressed.
  • If it does exist, where this particular form is defined to make sure that the revision log field is actually being included in the form definition.

Any insights on the above? I'm using the lightning distribution, so it's possible that there's some sort of override going on there, but I figured I should be checking in core first just in case.

The overall goal here for bounty award is to have a functional revision log message field on the form.

enter image description here

3
+50

I've added my initial patch to the issue - https://www.drupal.org/project/drupal/issues/3033516#comment-13136184

Adding this chunk to the init method of the OverridesEntityForm seems to do the trick, at least for nodes. We'll see what core maintainers come back with, but hopefully this can help you in the meantime.

  /**
   * {@inheritdoc}
   */
  protected function init(FormStateInterface $form_state) {
    parent::init($form_state);

    $form_display = EntityFormDisplay::collectRenderDisplay($this->entity, $this->getOperation(), FALSE);
    $form_display->setComponent(OverridesSectionStorage::FIELD_NAME, [
      'type' => 'layout_builder_widget',
      'weight' => -10,
      'settings' => [],
    ]);

    $section_storage = $this->getSectionStorage();
    $entity = $section_storage->getContextValue('entity');
    $entity_type = $entity->getEntityType();
    if ($entity_type->isRevisionable()) {
      $revision_log_message_form_item = $entity_type->getRevisionMetadataKey('revision_log_message');
      $log_field_definition = $entity->getFieldDefinition($revision_log_message_form_item);
      $log_field_revision_message_form_data = $log_field_definition->getDisplayOptions('form');
      $form_display->setComponent($revision_log_message_form_item, $log_field_revision_message_form_data);  
    }

    $this->setFormDisplay($form_display, $form_state);
  }
  • 1
    Nice, but I think you need to check first if the entity supports revision – Ismail Cherri Jun 6 at 17:49
  • Good call - Updated the post here, and the D.O. ticket. Also updated with recommendation from Tim Plunkett (core maintainer) to use $this->getSectionStorage() – Tyler Fahey Jun 6 at 18:29
  • 1
    Thanks @TylerFahey, since you've got the issue queue rolling I'm accepting this as the answer. If anybody else hits this, check the issue noted above for the most up to date patch. – Mrweiner Jun 7 at 20:22
0

It seems a bug in the Layout Builder Module.
I found an issue on the Drupal Core issue queue with the same exact behaviour. Strangely, it is marked as "Closed (cannot reproduce)"
I did create a clean Drupal 8 instance, enabled Layout Builder for the basic page content type with enabled revisions.
I saw the same exact behaviour. Additionally, log messages were only saved with "edit" form and not with the "layout" form. So, it is definitely a core layout builder module bug and not related to the distribution you're using.


Suggestion: Open a new ticket on the Drupal Core issue tracker

  • Thanks for the confirmation on this. I came across the issue before but couldn't find it again -- glad I'm not going completely crazy. If nobody comes through here with a further fix before the bounty ends I'll award it to you. – Mrweiner Jun 5 at 23:46
  • Thanks. I tried to look for a fix, but it seems related to how Layout builder loads the entity form. I'll keep you posted if I find anything – Ismail Cherri Jun 6 at 7:30
  • Agreed. I'm lost as to how it generates the form. I can't seem to find its definition anywhere – Mrweiner Jun 6 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.