1

The First Name must also show on page 1 (and page 3/4/5/6 etc). If I'd just have two pages I could show Existing Contact on page 1 (display name) and then show First Name on page 2 but I've got 3/4/5/6/7/8 pages

First Name is an input[readonly] field - just a handrail to remind the parents which child's info they are updating to e.g. get the allergies and the busing filled out correctly.

Only easy 'option' I can see thus far is to put First Name (of Student 1) in a Fieldset Student 1 (on page 1). Then add a Fieldset Student 1 (on page 2) - and move the custom fields from Student 1 that need to go to page 2 (healthcare / allergy fields in this case) into that. Same for page 3 (selecting busing options). Etc. But then the parents have to remember who Student 1 (2/3/4) is all the way through.

Any ideas on how one could re-show Existing Contact fields on a next page? I've been thinking about perhaps creating a Student Name field in each of the custom data sets for contact type Student - and then PHP populate that with = First Name (or Display name) - make them readonly etc - pull these into the Webform - and they'd always 'travel' to any page with the rest of the fields in their dataset. But that would look a bit odd on the Student's CiviCRM Contact summary page.

  • I'm going to think about doing this with a hook form_alter [to try and take the value of First Name on page1 - and then to push it to into a Markup element on page2]. – KarinG - Semper IT Aug 11 '15 at 14:56
2

I could not see a way to get tokens working in webform conditionals - so I've worked it out with a hook_form_alter hook. It's like building your own token.

On page 2 create a fieldset:

Label = STUDENT1TOKEN - Health
Field Key = student1token

Then in code you can replace your token: STUDENT1TOKEN with any value that has already been submitted on page 1 of this specific webform.

Dependence on field_key is not great - in a next pass I should probably just scan for STUDENT1TOKEN in all fieldset titles, [and then of course STUDENT2TOKEN, STUDENT3TOKEN, STUDENT4TOKEN].

function webform_civicrm_mystuff_form_webform_client_form_342_alter(&$form, &$form_state, $form_id) {
  // if we're on page2...
  if ($form['details']['page_num']['#value'] == 2) {
    if (isset($form_state['input']['submitted']['layoutbox_students']['civicrm_3_contact_1_fieldset_fieldset']['civicrm_3_contact_1_contact_first_name'])) {
      $student1_first_name = $form_state['input']['submitted']['layoutbox_students']['civicrm_3_contact_1_fieldset_fieldset']['civicrm_3_contact_1_contact_first_name'];
      $text_fieldset_title = $form['submitted']['student1token']['#title'];
      $new_fieldset_title =  str_replace('STUDENT1TOKEN', $student1_first_name, $text_fieldset_title);
      $form['submitted']['student1token']['#title'] = $new_fieldset_title;
    }
  }
}

End result: your CiviCRM contact's name in a fieldset label on the next page! contact's name in fieldset title

2

I know this question is pretty old but I recently had a similar requirement for a client where they wanted the user to see the value of a field they had entered on the first page to be displayed on subsequent pages.

In this example we want the value of first name to be displayed on page two that has been entered on page one.

Page 1 of the webform as seen by the user -

enter image description here

The value of first name as entered on page one can be displayed on page two by using a token in a markup field in the below format -

[submission:values:civicrm_1_contact_1_fieldset_fieldset:civicrm_1_contact_1_contact_first_name]

enter image description here

The token is built using the field set form key and the field name form key –

enter image description here

Page 2 of the webform as seen by the user with the value of first name displayed -

enter image description here

  • Yes - and thank you for the nice/clear screenshots - that will be helpful to many. Where it got really tricky in our case was the conditionals: only print the tokens for kids names 2,3,4 if they are 2,3,4 kids – KarinG - Semper IT Jul 17 '18 at 19:47
1

You might be able to do this with webform conditionals. Take your first idea (putting first_name on page 1 as a hidden field) then create some extra throwaway webform fields (like name_page_2, name_page_3, etc) and set up a webform conditional rule to fill their values with the value from page 1.

  • To fill it - I'd need to add a token so that it would be something like: – KarinG - Semper IT Aug 11 '15 at 15:34
  • if... then... name_page_2 - is - set to - a token - I can't seem to get tokens to work here - not even [current-user:name] - it just fills it as [current-user:name]. – KarinG - Semper IT Aug 11 '15 at 15:40
  • I'm not sure if it helps (I'm adding it here just in case), but this is similar to the cross-page-data requirements of this question: civicrm.stackexchange.com/questions/604/… – Laryn - CEDC.org Aug 11 '15 at 15:59

Your Answer

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

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