You are here

public function IconField::validate in Icon API 8

Validate the icon field.

File

modules/icon_field/src/Plugin/Field/FieldWidget/IconField.php, line 45
Contains \Drupal\icon_field\Plugin\Field\FieldWidget\IconField.

Class

IconField
Plugin implementation of the 'icon_default_widget' widget.

Namespace

Drupal\icon_field\Plugin\Field\FieldWidget

Code

public function validate($element, FormStateInterface $form_state) {
  $value = $element['#icon'];
  if (strlen($value) == 0) {
    $form_state
      ->setValueForElement($element, '');
    return;
  }
}