Compatibility with form_mode_manager module

Created on 13 November 2018, over 6 years ago
Updated 11 September 2023, over 1 year ago

I'm using this module in combination with form_mode_manager. ( https://www.drupal.org/project/form_mode_manager )
Form_mode_manager creates form id's like "user_MYNAME_form" which this module does not allow...

Attached is a patch that checks and allows these custom form id's.

I've also included en extra check to see if the "roles" field is actually in the form. This is not strictly necessary for this patch. But it also guarantees compatibility with the account_field_split module, which allows to disable the roles field.

🐛 Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇧🇪Belgium weseze

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 weseze

    Seems this is not going to get fixed, so I will close this issue.

    Fro anyone else that wants this, I'm currently using this fix in custom code.

    
    /**
     * Implements hook_form_alter().
     */
    function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
      $form_mode_manager_exists = Drupal::moduleHandler()->moduleExists('form_mode_manager');
      if ($form_mode_manager_exists && function_exists('roleassign_form_alter')) {
        /** @var \Drupal\form_mode_manager\FormModeManager $form_mode_manager */
        $form_mode_manager = \Drupal::service('form_mode.manager');
        $form_modes = $form_mode_manager->getFormModesByEntity('user');
        foreach ($form_modes as $name => $form_mode) {
          if ($form_id === 'user_' . $name . '_form') {
            roleassign_form_alter($form, $form_state, 'user_form');
          }
        }
      }
    }
    
Production build 0.71.5 2024