I am using Workflow with a custom content type. I have the Workflow state transition form as a sidebar on my node view page. I made the workflow states into buttons so that you can choose which state to transition to.

How can I remove buttons that are the same state as the node? For example: If the node is already in Draft state, the Draft button should not be shown. If it's in Declined mode, the Declined button should not be shown.

1 Answer 1


Implement hook_form_workflow_transition_form_alter().

 * Implements hook_form_form_id_alter().
 * Alter transition form to remove current state button.
function MYMODULE_form_workflow_transition_form_alter(&$form, &$form_state, $form_id) {

  // Get current state to remove current state button.
  $current_sid = $form['workflow']['workflow_sid']['#default_value'];

  // By default workflow button label became (Update workflow) if the options
  // count equal one. So, We will use the state label name instead of
  // (Update workflow).
  // Check if option count equal one.
  if (is_array($form['workflow']['workflow_sid']['#options']) && (count($form['workflow']['workflow_sid']['#options']) == 1)) {
    $submit_label = current($form['workflow']['workflow_sid']['#options']);
    $form['workflow']['actions']['submit']['#value'] = $submit_label;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.