I've build a multi-step form using the following tutorial. Which is quite nice!

Can I also change a block based on the step you're in?

I'm my case I have an activity registration form, build according to the example above. Step 1: choose a location, Step 2: Choose a time, Step 3: Confirm.

I also have a custom block next to the form which has information on the activity a user is going to register for. (based on the url variables). Can I change the contents of the block according to the step the user is in?

I would think this step information needs to be passed to the block, based on the step your in, but how?


I just tried something, but this is not going to be right I have this hook_block_view:

function MODULE_block_view($delta = '') {
  $block = array();

  switch($delta) {
    case 'MODULE_info_block' :
      $block['content'] = MODULE_info_block_view();

  return $block;

And the block construction:

function MODULE_info_block_view($test = 'testdata') {

In the form I can call:

MODULE_info_block_view('this is form data')

But offcourse I get two dpm messages then... Is it allowed to call the block construction somewhere in a form?

  • If your path changes, is it consistent for each step no matter the user or version? If the url doesn’t change per step per user, I’d say you could just create three blocks to show on those specific urls. – Prestosaurus Jun 23 '19 at 21:13
  • The multistep form just has one path, but the display of the form changes according to the step the user is in... I works by storing the form data in `form_state' and passing this on. Which implies I can't create three blocks, because I haven't got three specific urls, no? (perhaps I'm missing something) – dietervdf Jun 23 '19 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.