Salut,

The behavior I am currently seeing with forms_steps and users is that forms_steps applied to user entities creates a user registration method, however, there is no way to edit existing users. (It is slightly possible that my modified version on the module perms has caused this; I'll fork shortly and test that).

Presuming that I'm seeing normal behavior, do we have a path to allowing forms_steps to edit exiting user data ("over-ride ~/user/edit") ? Glad to put some coding effort in myself (I'm about to look at that, as well).

Best/thanks/merci, Ken

Comments

1kenthomas created an issue. See original summary.

1kenthomas’s picture

ggj’s picture

any updates on this?

ggj’s picture

I thought I'll update it for someone who comes here in future.

Similar to the drush command created in the related ticket, I add the current user in the current workflow in a 'forms_steps.step_change_event'.
Note: you will have to do some cleanup like the button label and messages.

We can do the same thing for other content types as well. However, step_change_event is called after the end of a step (hence, it can't be called for step 1).

Not the cleanest solution, but it solves my issue without making any change in forms_steps or writing custom code.

      $redirectParams = $event->formState->getRedirect()->getRouteParameters();
      $properties = [
        'instance_id' => $redirectParams["instance_id"],
        'entity_type' => 'user',
        'bundle' => 'user',
        'step' => $toStepId,
        'entity_id' =>  \Drupal::currentUser()->id(),
        'form_mode' => 'user.{form_mode}',
        'forms_steps' => $formsStepsId,
      ];

      $entities = $this->workflow->loadByProperties($properties);

      if (empty($entities)) {
        $this->workflow
          ->create($properties)
          ->save();
      }