I want to add a progressbar like this at top of all steps:

Step(1) --> Step(2) --> Step(3) --> Step(4)

Code:

function mymodule_form_contenttype_node_form_alter(&$form, &$form_state, $form_id) {

   $steps = '<div id="sub_nav"><ul class="steps-bc">';
   $additional_class = '';
   $counter = 0;
   foreach ($form['#steps'] as $step) {
      $steps .= '<li class="' . $step->step_name '">' . $step->label . "</li>";
   }
   $steps .= '</ul></div>';

   $form['steps_div'] = array(
      '#markup' => $steps
   );

   $form['#step_children']['steps_div'] = 'step_1';
}

Using above code I can only add the form element to one step(step_intro), but it should be shown on top of all steps. Form element is not a input field so it shouldn't cause any error. How do I add it to all steps?

I need something like:
$form['#step_children']['steps_div'] = array('step_1', 'step_2', 'step_3', 'step_4');
But it doesn't work.

Comments

stBorchert’s picture

You don't need this as there is already something like this built into Multistep Nodeform.
The module creates a block with information about all available steps (highlighting the current one). You need to go to admin/structure/block and move the block named "Multistep Nodeform: Step information" into the proper region.

hth,

 Stefan

hp_ir’s picture

Thanks. It is not documented neither in README.txt nor in the project page , is it?

rooby’s picture

Title: Add a form element to all steps programmatically » Document the steps block in the README.txt file
Version: 7.x-1.5 » 7.x-1.x-dev
Category: Support request » Task
Issue summary: View changes

  • stBorchert committed a89d30b on 7.x-1.x
    Issue #2051793: document usage of step information block.
    
stBorchert’s picture

Status: Active » Fixed

I've added a note to the README.txt.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.