Node previews don't work when adding group node

Created on 15 February 2017, over 7 years ago
Updated 25 September 2023, about 1 year ago

I see that Drupal\group\Entity\Controller\GroupContentController is now responsible for rendering the edit form when nodes are being created via group. Previously there were multistep forms in Gnode that did this and allowed manipulation of the node actions, in particular.

By calling $this->entityFormBuilder()->getForm($entity, $operation, $extra); in the createForm method of GroupContentController, it doesn't allow easy overrides of the node actions. Of note is the "preview" button, which disappears on content that should have its preview capabilities working.

I believe preview not being displayed is a bug, probably because of the access check that the preview button performs in the node module.

On the other hand, I'd be OK overriding the NodeForm class altogether if I knew of a good way to do so. hook_entity_type_alter() usually allows this but it doesn't seem to be working in this case.

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    The approach here is actually quite clean. If someone can port it to 2.x/3.x then I'd be willing to commit this. Not a fan that it's node-specific, but at least it bridges the gap between now and when I get around to solving the issue of extra entity form actions (other than save/cancel).

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    9,627 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    9,627 pass
  • Patches for 2.x and 3.x. I've applied the 2.x patch on my dev site, but am only hopeful that the 3.x patch is functional.

    There's a reroll for the changed `use` statements. Renamed 'group_content_enabler' to 'group_relation'. For 3.x updated the route to 'entity.group_relationship.create_form'.

    Interdiff from #21 failed so it's instead a diff of the actual patch files.

  • 🇧🇪Belgium msnassar

    Here is another approach:
    - Instead of using hook_node_create_access, it is decorating the node preview access check service.
    - Instead of checking the create permission, it is delectating the access check to the access control handler.
    - Instead of using the hook_form_alter, it is using hook_form_BASE_FORM_ID_alter to alter the preview form.
    This patch works with group 2 only. I will create another one for group 3 if the approach is acceptable.
    @kristiaanvandeneynde please let me know thoughts?

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9,621 pass, 4 fail
  • 🇧🇪Belgium msnassar

    Sorry, I forgot to add the decorator. Here is new patch.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9,628 pass
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    I do like the decorator approach. Will have to find some time to go into detail, but could try and review this as part of my 3.3.0 release plan.

Production build 0.71.5 2024