开发者

Show a previous page value in Drupal multi-step webform?

In a multi-step Drupal webform, is it possibl开发者_高级运维e to show a value entered in a previous-step page?

For example, the first step page captures a username field as "John", is it possible to show a greeting in next step page, showing Hello John, ... ?

p.s. for anonymous user.


I know this is old, but I needed the same thing so I hope this helps others in search.

I needed values from a previous Webform step for my custom Webform component. The _webform_redner_[component](...) hook doesn't provide the form or form_state, also the previous steps' data (more than previous step that was just submitted) isn't in the $_POST.

To solve this, I manually retrieve the form from Drupal's form caching system using the form_build_id which is in the $_POST variable.

  /* ... */
  $form_state = array();
  // Get the form_state to pass on to our build function.
  // Webforms doesn't provide it at this point so we'll need to manually get it using the form's build_id.
  $form = form_get_cache($_POST['form_build_id'], $form_state); 
  /* ... */

You now have the entire form and form_state that also includes previous steps' values.


Have a look at multistep form example here: http://drupal.org/node/717750

The general idea is that in the submit function you save all posted values to $form_state['storage'], which you can later access on the next steps.

Edit: Have a look at the example with both Prev and Next buttons I have just created: http://zgadzaj.com/basic-drupal-multipart-form-example-with-previous-and-next-buttons

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜