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

Created on 24 January 2020, almost 5 years ago
Updated 6 August 2024, 5 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

✨ Feature request
Status

Needs work

Version

3.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.

  • 🇺🇸United States mlncn Minneapolis, MN, USA
  • Issue was unassigned.
  • 🇺🇸United States mlncn Minneapolis, MN, USA
  • Status changed to Needs work 5 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");
      }
    }
    
Production build 0.71.5 2024