You are here

public function SimpleStockLevelWidget::validateSimple in Commerce Stock 8

Simple stock form - Used to update the stock level.

@todo: This is not go live ready code,

File

modules/field/src/Plugin/Field/FieldWidget/SimpleStockLevelWidget.php, line 264

Class

SimpleStockLevelWidget
Plugin implementation of the 'commerce_stock_level' widget.

Namespace

Drupal\commerce_stock_field\Plugin\Field\FieldWidget

Code

public function validateSimple($element, FormStateInterface $form_state) {
  if (!is_numeric($element['#value'])) {
    $form_state
      ->setError($element, $this
      ->t('Stock must be a number.'));
    return;
  }

  // @todo Needs to mark element as needing updating? Updated qty??
}