private function AdminForm::rebuildForm in Webform CiviCRM Integration 8.5
On rebuilding the form
1 call to AdminForm::rebuildForm()
- AdminForm::buildForm in src/
AdminForm.php - Build admin form for civicrm tab of a webform
File
- src/
AdminForm.php, line 156 - Webform CiviCRM module's admin form.
Class
- AdminForm
- @file Webform CiviCRM module's admin form.
Namespace
Drupal\webform_civicrmCode
private function rebuildForm() {
// The following should mimic this line.
// $this->settings = wf_crm_aval($this->form_state->getStorage(), 'vals', $this->form_state->getValues());
$this->settings = $this->form_state
->get('vals') ?: $this->form_state
->getValues();
$this
->rebuildData();
// Hack for nicer UX: pre-check phone, email, etc when user increments them
if (!empty($_POST['_triggering_element_name'])) {
$defaults = [
'phone' => 'phone',
'email' => 'email',
'website' => 'url',
'im' => 'name',
'address' => [
'street_address',
'city',
'state_province_id',
'postal_code',
],
'billing' => [
'first_name',
'last_name',
'street_address',
'city',
'postal_code',
'state_province_id',
'country_id',
],
];
foreach ($defaults as $ent => $fields) {
if (strpos($_POST['_triggering_element_name'], "_number_of_{$ent}")) {
if ($ent == 'billing') {
foreach ((array) $fields as $field) {
$this->settings["civicrm_1_contribution_1_contribution_{$ent}_address_{$field}"] = 1;
}
continue;
}
list(, $c) = explode('_', $_POST['_triggering_element_name']);
for ($n = 1; $n <= $this->data['contact'][$c]["number_of_{$ent}"]; ++$n) {
foreach ((array) $fields as $field) {
$this->settings["civicrm_{$c}_contact_{$n}_{$ent}_{$field}"] = 1;
}
}
}
}
}
// This replaces: unset($this->form_state['storage']['vals']);
$this->form_state
->set('vals', NULL);
}