You are here

public static function StockLevelWidgetBase::validateSettingsForm in Commerce Stock 8

Validates the settings form.

Parameters

array $element: The settings form element.

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

File

modules/field/src/Plugin/Field/FieldWidget/StockLevelWidgetBase.php, line 159

Class

StockLevelWidgetBase
Provides the base structure for commerce stock level widgets.

Namespace

Drupal\commerce_stock_field\Plugin\Field\FieldWidget

Code

public static function validateSettingsForm(array $element, FormStateInterface $form_state) {
  $value = $form_state
    ->getValue($element['#parents']);
  if (empty($value['allow_decimal'])) {
    $value['step'] = '1';
  }
  unset($value['allow_decimal']);
  $form_state
    ->setValue($element['#parents'], $value);
}