You are here

public function RulesListForm::submitForm in Custom filter 2.0.x

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

src/Form/RulesListForm.php, line 211

Class

RulesListForm
Defines a form to list the rules.

Namespace

Drupal\customfilter\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->entity = CustomFilter::load($form_state
    ->getValue('fid'));
  foreach ($form_state
    ->getValue('rules') as $rule) {
    $item = [
      'rid' => $rule['rid'],
      'prid' => $rule['prid'],
      'fid' => $this->entity
        ->id(),
      'enabled' => $rule['enabled'],
      'weight' => $rule['weight'],
    ];
    $this->entity
      ->updateRule($item);
  }
  $this->entity
    ->save();
}