0

With a multi-page webform.

  • Page 1: choose country
  • Page 2: choose industry
  • Page 3: choose from a list of people that support the country and industry.

#validate handler added

$form['#validate'][] = '_cbifasttrackcert_webform_validate_sector_country';

Adding the items to the list

$verifier_options = $verifierHandler->formatVerifierOptions($verifiers);
$form['#node']->webform['components'][$choose_verifiers_cid]['extra']['items'] = 
$verifier_options;
$form_state['webform']['component_tree']['children'][$choose_verifiers_cid]['extra']['items'] = $verifier_options;

Which is fine throughout the form, the values don't get submitted as there is a check that values are in the node list.

The challenge is to email a response based on the values, as only $submission is available.

When submitting a webform, node_load is used to load a clean version of the options in select.inc. These options are used to check whether any valid options have been submitted, with options not in the list being discarded.

web/sites/all/modules/contrib/webform/components/select.inc has _webform_select_options() with options to provide a callback or filter based on a token.

I'm not sure how to access form_state using either of these options? Similarly hook node_load does have form_state to allow the options to be discovered?

How to filter a select list based on a token? How to load the form data in a callback?

1 Answer 1

0

The secret is to load all the possible responses in hook_node_load. They are a valid choice, even if submitted. I made it an associative array so that the indexes don't change.

function module_node_load($nodes, $types) {
  $choose_verifier_no_verifier_cid = webform_get_cid($webform_node, MyModuleHelper::CHOOSE_VERIFIER_NO_VERIFIER_WEBFORM_KEY)[0];

  $verifier_options = MyModuleHelper::chooseAllVerifiers();
  $webform_node->webform['components'][$choose_verifiers_cid]['extra']['items'] = $verifier_options;
  $webform_node->webform['components'][$choose_verifier_no_verifier_cid]['extra']['items'] = $verifier_options;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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