I'm trying to hide the 'previous' and 'next' buttons via form_alter, based on my specific conditions, but I can't. Why?

I'm using the follow code into form_alter:

$form['actions']['previous']['#access'] = FALSE;

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tregismoreira’s picture

So... Since (mysteriously) it's not possible to disable this buttons in form alter, I was forced to implement a feature to disable these buttons in step configuration. The attached patch implements three new options:

  • Disable the 'Previous' button in this step.
  • Disable the 'Next' button in this step.
  • Disable the 'Skip' button in this step.

Feedbacks are welcome! :)

fugazi’s picture

I would also appreciate a response form for the module authors know if you can use it that way.

regards

maijs’s picture

Multistep Nodeform sets module weight to 100 upon installation (see msnf_install() in msnf.install) therefore you need to place your form alter hook in a module whose weight is greater than 100 in order to control the buttons added by Multistep Nodeform module.

maijs’s picture

Issue summary: View changes

Fix the code.

bradjones1’s picture

Issue summary: View changes
Status: Active » Needs review

Status bump; I don't see why we couldn't add this option in the UI per this patch?

bradjones1’s picture

Also one workaround here (without hacking module weights and waiting for this patch to be RTBC) is to add a function callback into the form's #pre_render array, where you can then make changes to the $form before it's rendered, but after MSNF has done its thing. The function signature is a little different from a form_alter but it's the same idea.

rooby’s picture

Title: Why it's not possible to hide the 'previous' and 'next' buttons? » Allow configuration of the 'previous' and 'next' button text and disabled status
Version: 7.x-1.5 » 7.x-1.x-dev
Category: Bug report » Feature request
rooby’s picture

Title: Allow configuration of the 'previous' and 'next' button text and disabled status » Allow configuration of the 'previous' and 'next' button text and hiding buttons
rooby’s picture

rooby’s picture

Title: Allow configuration of the 'previous' and 'next' button text and hiding buttons » Allow hiding of the 'previous' and 'next' buttons

Oops, sorry for the mis-titling and comment spam.

stBorchert’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#1967306: Allow users to hide the skip button via hook_msnf_info_steps_alter()

Committed some code so the buttons "previous", "next" and "skip" can be hidden using hook_msnf_info_steps_alter().

@see #1967306: Allow users to hide the skip button via hook_msnf_info_steps_alter() and msnf.api.php for further reference.