You are here

protected function TransactionTypeFormBase::saveOptions in Transaction 8

Process submitted options.

Parameters

array $form: The form definition.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

1 call to TransactionTypeFormBase::saveOptions()
TransactionTypeFormBase::save in src/Form/TransactionTypeFormBase.php
Form submission handler for the 'save' action.

File

src/Form/TransactionTypeFormBase.php, line 230

Class

TransactionTypeFormBase
Base form for transaction type forms.

Namespace

Drupal\transaction\Form

Code

protected function saveOptions(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\transaction\TransactionTypeInterface $transaction_type */
  $transaction_type = $this->entity;
  $new_options = [];
  foreach (isset($form['options']) ? array_keys($form['options']) : [] as $option_key) {
    if ($value = $form_state
      ->getValue($option_key)) {
      $new_options[$option_key] = $value;
    }
  }
  $transaction_type
    ->setOptions($new_options);
}