You are here

public function CartSettingsForm::submitForm in Basic cart 8

Same name and namespace in other branches
  1. 8.6 src/Form/CartSettingsForm.php \Drupal\basic_cart\Form\CartSettingsForm::submitForm()
  2. 8.0 src/Form/CartSettingsForm.php \Drupal\basic_cart\Form\CartSettingsForm::submitForm()
  3. 8.2 src/Form/CartSettingsForm.php \Drupal\basic_cart\Form\CartSettingsForm::submitForm()
  4. 8.3 src/Form/CartSettingsForm.php \Drupal\basic_cart\Form\CartSettingsForm::submitForm()
  5. 8.4 src/Form/CartSettingsForm.php \Drupal\basic_cart\Form\CartSettingsForm::submitForm()
  6. 8.5 src/Form/CartSettingsForm.php \Drupal\basic_cart\Form\CartSettingsForm::submitForm()

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 ConfigFormBase::submitForm

File

src/Form/CartSettingsForm.php, line 267
Contains \Drupal\basic_cart\Form\CartSettingsForm

Class

CartSettingsForm
Configure basic_cart settings for this site.

Namespace

Drupal\basic_cart\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $content_types = $this
    ->config('basic_cart.settings')
    ->get('content_type');
  $this
    ->config('basic_cart.settings')
    ->set('cart_page_title', $form_state
    ->getValue('basic_cart_cart_page_title'))
    ->set('empty_cart', $form_state
    ->getValue('basic_cart_empty_cart'))
    ->set('cart_block_title', $form_state
    ->getValue('basic_cart_cart_block_title'))
    ->set('view_cart_button', $form_state
    ->getValue('basic_cart_view_cart_button'))
    ->set('cart_update_button', $form_state
    ->getValue('basic_cart_cart_update_button'))
    ->set('cart_updated_message', $form_state
    ->getValue('basic_cart_cart_updated_message'))
    ->set('quantity_status', $form_state
    ->getValue('basic_cart_quantity_status'))
    ->set('quantity_label', $form_state
    ->getValue('basic_cart_quantity_label'))
    ->set('price_status', $form_state
    ->getValue('basic_cart_price_status'))
    ->set('price_label', $form_state
    ->getValue('basic_cart_price_label'))
    ->set('price_format', $form_state
    ->getValue('basic_cart_price_format'))
    ->set('total_price_status', $form_state
    ->getValue('basic_cart_total_price_status'))
    ->set('total_price_label', $form_state
    ->getValue('basic_cart_total_price_label'))
    ->set('currency_status', $form_state
    ->getValue('basic_cart_currency_status'))
    ->set('currency', $form_state
    ->getValue('basic_cart_currency'))
    ->set('vat_state', $form_state
    ->getValue('basic_cart_vat_state'))
    ->set('vat_value', $form_state
    ->getValue('basic_cart_vat_value'))
    ->set('add_to_cart_button', $form_state
    ->getValue('basic_cart_add_to_cart_button'))
    ->set('added_to_cart_message', $form_state
    ->getValue('basic_cart_added_to_cart_message'))
    ->set('add_to_cart_redirect', $form_state
    ->getValue('basic_cart_add_to_cart_redirect'))
    ->set('content_type', $form_state
    ->getValue('basic_cart_content_types'))
    ->set('order_status', $form_state
    ->getValue('basic_cart_order_status'))
    ->set('use_cart_table', $form_state
    ->getValue('basic_cart_use_cart_table'))
    ->save();
  Utility::createFields();
  foreach ($form_state
    ->getValue('basic_cart_content_types') as $key => $value) {
    $content_types[$key] = $value ? $value : $content_types[$key];
  }
  $this
    ->config('basic_cart.settings')
    ->set('content_type', $content_types)
    ->save();
  parent::submitForm($form, $form_state);
}