Anyway to disable/hide the "Add node as xxxx" local action

Created on 24 January 2020, over 5 years ago
Updated 6 August 2024, 9 months ago

Firstly thanks for the module, it really seems like something that should be moved into core someday and I am looking forward to that day.

I am using this module to split a very large Node edit form into smaller forms, I do not want/need the "Add node as XXX" button on the add content screen.

Is there any way to disable this button from showing? Currently, I plan to just apply a patch locally to remove this behaviour but wondering if there is another way.

Thanks

πŸ’¬ Support request
Status

Needs review

Version

2.0

Component

Documentation

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA
  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA
  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Patch does not apply, probably only needs minor re-roll.

    I see it disables the action links for form mode manager globally. This is probably a useful option but personally i would go for being able to hide or rename any specific action or operations link generated by Form mode manager, if i were to take this on. But a couple of alter hooks makes that possible too.

    In an `example.module` file in your custom Example moduleβ€” presuming you are not using bundle subclasses for your content, the ProgramApplication parts can be dropped and this will still work:

    use Drupal\example\Entity\ProgramApplication;
    
    /**
     * Implements hook_menu_local_actions_alter().
     */
    function example_menu_local_actions_alter(&$local_actions) {
      // Remove "Create as" link for the content form mode 'form_mode_edit_only'.
      unset($local_actions['form_mode_manager.action:node.form_mode_edit_only']);
      // Shorten "Create content as form_mode" link to "Create form mode".
      $local_actions['form_mode_manager.action:node.application_forms']['title'] = t("Create application forms");
    }
    
    /**
     * Implements hook_entity_operation_alter().
     */
    function example_entity_operation_alter(&$operations, $entity) {
      if ($entity instanceof ProgramApplication and isset($operations['application_forms'])) {
        // Shorten the edit link e.g. it the per-node dropdown on the content admin listing page.
        $operations['application_forms']['title'] = t("Edit application forms");
      }
    }
    
  • First commit to issue fork.
  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    tim-diels β†’ changed the visibility of the branch 3.x to hidden.

  • Pipeline finished with Failed
    20 days ago
    #481917
  • Pipeline finished with Failed
    20 days ago
    #481923
  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Created MR for 3.x based on the work done above.

    @mlncn I like the suggestion you make, but it will take more time and is more complex to get this done. Maybe split that to a new feature request?

    Test is failing probably because the cache is not getting cleared properly to hide the link.

    But to me this also seems to be incomplete and it should however take care for individual entity types. Now its a global setting but only hiding on the admin/content page. So either have a global setting to hide it everywhere (not a fan of this) or have the setting per entity type.
    So I guess this code will need some refactoring to have this as an option for every entity type.

Production build 0.71.5 2024