Closed (fixed)
Project:
Webform
Version:
7.x-3.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2013 at 16:13 UTC
Updated:
13 Mar 2014 at 23:33 UTC
Jump to comment: Most recent
I'm creating a webform with multiple pages. On the first page, I ask for "Name" (textfield), and on the second page, I would like to have a markup component that incorporates the value entered for "Name" on the first page.
I have tried using webform's token system in Webform 3.x and the new token functionality in Webform 4.x, as well as hook_form_alter(), all to no avail.
In regard to the later, in glue.module I defined:
function glue_form_alter(&$form, &$form_state, $form_id) {
if (preg_match("/webform/i", $form_id)) {
dsm($form);
}
}
and the resulting array displays the "name" component value (from page one) as empty on page two.
Would someone please help me?
Comments
Comment #1
carsonwI found the solution after some elbow grease. The previously entered values are stored in the $form_state variable. So, I check to see if the value exists in the $form_state array and if it does, then I perform a str_replace() on the markup component in the $form array, like so:
In the original markup component value, I had entered: Hello TOKEN1. where TOKEN1 is my own custom token text.
Comment #2
cybermache commentedI'm trying to achieve the exact same thing. I have a form that is using a select list on the first page and I'd like to insert the selected value into a paragraph markup on the second page.
I'm a bit confused by your solution, are you applying this function in a custom module named 'glue'?
Or has it been implemented into a webform branch that can be downloaded?
Any extra info on how you got this to work would be awesome.
Thanks
Comment #3
carsonw@cybermache - Yes, sorry for the confusion. I am using hook_form_alter in a custom module named 'glue'.