We needed to let users to "go back" to the final step of the multi-step form from a node checkout workflow [ i.e. node/add/type multi-step > checkout <> node/NID/edit] as one continuous step form, and during the node/add part we hide the skip, but on the edit part, we needed to be able to go to any step.
So I used the alter to update the available buttons if it was an edit (note: only possible with the patch from #1967284: Calling drupal_alter() with too many parameters) and this required this patch.
This only targets skip, but could be extended out to the other buttons.
i.e. Example usage:
/**
* Implements hook_msnf_info_steps_alter().
*/
function HOOK_msnf_info_steps_alter(&$steps_cached, $entity_type, $bundle) {
// Provides a fallback if http://drupal.org/node/1967284 is reverted.
if (is_array($entity_type)) {
extract($entity_type, EXTR_SKIP);
$bundle = $entity_type['bundle'];
$entity_type = $entity_type['entity_type'];
}
if ($entity_type == 'node' && $bundle == 'goto') {
if (user_access('administer gotos')) {
$steps_cached[$entity_type][$bundle] = array();
}
elseif (!empty($form['node'])) {
$node = $form['node'];
if (!empty($node->nid)) {
// Let users skip steps.
$steps = &$steps_cached[$entity_type][$bundle];
foreach ($steps as $key => $step) {
// Hiding the skip button requires the attached
// msnf-allow-users-to-remove-skip-button.patch
if (isset($step->format_settings['instance_settings']['buttons']['skip'])) {
unset($steps[$key]->format_settings['instance_settings']['buttons']['skip']);
}
// Allows editing from anywhere.
$steps[$key]->format_settings['instance_settings']['skip_non_required'] = 1;
}
}
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| msnf-allow-users-to-remove-skip-button.patch | 568 bytes | alan d. |
Comments
Comment #1
alan d. commentedComment #3
stborchertI've modified the patch so the other buttons can be hidden, too. Instead of using
unset()I decided to go with setting the buttons toFALSE(similar to hiding form elements using['#access'] = FALSE).Thanks for the start.
Comment #5
fabiansierra5191 commentedI know that this issue was close but I'd like to propose and alternative solution.
The msnf module has in the .install file a function to set the weight module to 100, so I set to 100 the weight my custom module in the install, after my hook_form_FORM_ID_alter() function I hide the skip button
$form['actions']['skip']['#access'] = FALSE;That worked for me and maybe it's a solution for someone with same issue without apply a patch.