Implementing hook_msfn_info_steps_alter with $form_state throws the following error:

Warning: Missing argument 5 for mymodule_msnf_info_steps_alter(), called in docroot/includes/module.inc on line 1101 and defined in mymodule_msnf_info_steps_alter() (line 845 of docroot/sites/all/modules/custom/mymodule/mymodule.module).

It seems that $form_state is not passed to this function. This seems similar to this issue. I suspect this could use a patch or the documentation should be modified to better describe how to use the api.

Comments

daggerhart’s picture

It took me a few issues to find a fix for this.

Patch here: https://drupal.org/node/1967284
And use of api hook here: https://drupal.org/node/1461948#comment-6897834

Resulting in an example that looks more like this:

/**
 * Alter the step definition that will be attached to a form.
 *
 * @param <array> $steps_cached
 *   List of steps. @see msnf_read_steps() for structure details.
 * @param <array> $context
 *   Contains $entity_type, $bundle, $form, and $form_state
 */
function hook_msnf_info_steps_alter(&$steps_cached, $context) {
  extract($context);
  if ($entity_type == 'node' && $bundle == 'article' && !empty($form['#node']->nid)) {
    // Disable steps on node/[nid]/edit for nodes of type "article".
    $steps_cached[$entity_type][$bundle] = array();
  }
}

Additionally, there is a mistake in the function msnf_attach_steps().

Find:
$steps = msnf_info_steps($entity_type, $bundle, $element, $form_state);
Replace with:
$steps = msnf_info_steps($entity_type, $bundle, FALSE, $element, $form_state);

Not sure if this is the accepted fix/implementation, but it works for me. Hope this helps.

rooby’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)
Related issues: +#1967284: Calling drupal_alter() with too many parameters

This is a duplicate of #1967284: Calling drupal_alter() with too many parameters, which has a patch to fix this.