You are here

function wf_crm_components_form_validate in Webform CiviCRM Integration 7.4

Same name and namespace in other branches
  1. 7.5 includes/wf_crm_admin_component.inc \wf_crm_components_form_validate()

Drupal FAPI validation callback for all-components form

1 string reference to 'wf_crm_components_form_validate'
webform_civicrm_form_alter in ./webform_civicrm.module
Implements hook_form_alter().

File

includes/wf_crm_admin_component.inc, line 750

Code

function wf_crm_components_form_validate($form, &$form_state) {
  $components = wf_crm_aval($form_state, 'values:components', array());
  foreach ($components as $cid => $component) {
    $component += $form['#node']->webform['components'][$cid];
    if ($component['form_key'] == 'civicrm_1_contribution_1_contribution_contribution_page_id') {

      // Iterate up through parents
      while ($component['pid']) {
        $component = $components[$component['pid']];
      }
      $weight = $component['weight'];
    }
  }
  if (isset($weight)) {
    foreach ($components as $cid => $component) {
      $component += $form['#node']->webform['components'][$cid];
      if ($component['type'] == 'pagebreak' && $component['weight'] > $weight) {
        form_error($form['components'], t('CiviCRM Contribution Billing Fields <em>must</em> be on the last page of the form.'));
      }
    }
  }
}