1

I know how to hook_alter a Webform build form. I also know how to validate it using a hook_validate.

Is there a chance to skip a certain Webform page when some validation code results in false?

I cannot find any solution ;-(

  • no ideas? I searched almost everywhere... – schulle877 Feb 28 '14 at 13:40
0

I has just found a solution for it. Perhaps, somebody can find more pretty realisation.

So, first step: Lets your 'hook_node_view' in custom module call early than webform 'hook_node_view', you can do it through hook_module_implements_alter() something like it:

function YOUR_MODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'node_view') {
    if(isset($implementations['YOUR_MODULE'])){
      $group = $implementations[YOUR_MODULE];
      unset($implementations[YOUR_MODULE]);
      $implementations = array_merge(array(YOUR_MODULE => $group), $implementations);
    }
  }
}

Second step: Remove unnecessary webform components from node object.

function YOUR_MODULE_node_view($node, $view_mode) {
  if (isset($node->webform['components']) && YOUR_CONDITION) {
    foreach ($node->webform['components'] as $key => $component) {
      if ($component['page_num'] == 2) {
        unset($node->webform['components'][$key]);
      }
    }
  }
}
| improve this answer | |

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.