protected function ProductAttributeForm::saveValues in Commerce Core 8.2
Saves the attribute values.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to ProductAttributeForm::saveValues()
- ProductAttributeForm::save in modules/
product/ src/ Form/ ProductAttributeForm.php - Form submission handler for the 'save' action.
File
- modules/
product/ src/ Form/ ProductAttributeForm.php, line 373
Class
Namespace
Drupal\commerce_product\FormCode
protected function saveValues(array $form, FormStateInterface $form_state) {
$delete_queue = $form_state
->get('delete_queue');
if (!empty($delete_queue)) {
$value_storage = $this->entityTypeManager
->getStorage('commerce_product_attribute_value');
$values = $value_storage
->loadMultiple($delete_queue);
$value_storage
->delete($values);
}
foreach ($form_state
->getValue([
'values',
]) as $index => $value_data) {
/** @var \Drupal\commerce\Plugin\Commerce\InlineForm\EntityInlineFormInterface $inline_form */
$inline_form = $form['values'][$index]['entity']['#inline_form'];
/** @var \Drupal\commerce_product\Entity\ProductAttributeValueInterface $value */
$value = $inline_form
->getEntity();
$value
->setWeight($value_data['weight']);
$value
->save();
}
}