public function Custom::submitConfigurationForm in Commerce Core 8.2
Form submission handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides TaxTypeBase::submitConfigurationForm
File
- modules/
tax/ src/ Plugin/ Commerce/ TaxType/ Custom.php, line 312
Class
- Custom
- Provides the Custom tax type.
Namespace
Drupal\commerce_tax\Plugin\Commerce\TaxTypeCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
if (!$form_state
->getErrors()) {
$values = $form_state
->getValue($form['#parents']);
$this->configuration['display_label'] = $values['display_label'];
$this->configuration['round'] = $values['round'];
$this->configuration['rates'] = [];
foreach (array_filter($values['rates']) as $rate) {
$this->configuration['rates'][] = [
'id' => $rate['rate']['id'],
'label' => $rate['rate']['label'],
'percentage' => (string) ($rate['percentage'] / 100),
];
}
$this->configuration['territories'] = [];
foreach (array_filter($values['territories']) as $territory) {
$this->configuration['territories'][] = $territory['territory'];
}
}
}