You are here

public function wf_crm_admin_component::adjustPageBreak in Webform CiviCRM Integration 7.4

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

Ensure page breaks are not placed after contribution page

File

includes/wf_crm_admin_component.inc, line 202

Class

wf_crm_admin_component

Code

public function adjustPageBreak() {
  $components = $this->node->webform['components'];
  foreach ($components as $cid => $component) {
    if ($component['form_key'] == 'civicrm_1_contribution_1_contribution_contribution_page_id') {

      // Iterate up through parents
      while ($component['pid']) {
        $component = $components[$component['pid']];
      }
      $min = $component['weight'];
    }
  }
  if (isset($min)) {
    $weight = $this->form['position']['weight']['#default_value'];
    $this->form['position']['weight'] = array(
      '#type' => 'value',
    );
    if ($weight >= $min) {
      $weight = $min - 1;
    }
    $this->form['position']['weight']['#value'] = $weight;
  }
}