public function PromotionListBuilder::submitForm in Commerce Core 8.2
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- modules/
promotion/ src/ PromotionListBuilder.php, line 297
Class
- PromotionListBuilder
- Defines the list builder for promotions.
Namespace
Drupal\commerce_promotionCode
public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($form_state
->getValue('enabled_promotions') as $id => $value) {
if (isset($this->enabledEntities[$id]) && $this->enabledEntities[$id]
->getWeight() != $value['weight']) {
// Save entity only when its weight was changed.
$this->enabledEntities[$id]
->setWeight($value['weight']);
$this->enabledEntities[$id]
->save();
}
}
}