ProductAttributesAddForm.php in Ubercart 8.4
File
uc_attribute/src/Form/ProductAttributesAddForm.php
View source
<?php
namespace Drupal\uc_attribute\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;
class ProductAttributesAddForm extends ObjectAttributesAddFormBase {
public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) {
$this->attributeTable = 'uc_product_attributes';
$this->optionTable = 'uc_product_options';
$this->idField = 'nid';
$this->idValue = $node
->id();
$this->attributes = uc_product_get_attributes($this->idValue);
return parent::buildBaseForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$form_state
->setRedirect('uc_attribute.product_attributes', [
'node' => $this->idValue,
]);
}
protected function attributesAdded() {
\Drupal::database()
->delete('uc_product_adjustments')
->condition('nid', $this->idValue)
->execute();
}
}