You are here

public static function ContentBlockPluginFieldWidget::validateElement in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_content_block/src/Plugin/Field/FieldWidget/ContentBlockPluginFieldWidget.php \Drupal\social_content_block\Plugin\Field\FieldWidget\ContentBlockPluginFieldWidget::validateElement()
  2. 8.8 modules/social_features/social_content_block/src/Plugin/Field/FieldWidget/ContentBlockPluginFieldWidget.php \Drupal\social_content_block\Plugin\Field\FieldWidget\ContentBlockPluginFieldWidget::validateElement()
  3. 10.3.x modules/social_features/social_content_block/src/Plugin/Field/FieldWidget/ContentBlockPluginFieldWidget.php \Drupal\social_content_block\Plugin\Field\FieldWidget\ContentBlockPluginFieldWidget::validateElement()
  4. 10.0.x modules/social_features/social_content_block/src/Plugin/Field/FieldWidget/ContentBlockPluginFieldWidget.php \Drupal\social_content_block\Plugin\Field\FieldWidget\ContentBlockPluginFieldWidget::validateElement()
  5. 10.2.x modules/social_features/social_content_block/src/Plugin/Field/FieldWidget/ContentBlockPluginFieldWidget.php \Drupal\social_content_block\Plugin\Field\FieldWidget\ContentBlockPluginFieldWidget::validateElement()

Form validation handler for widget elements.

Parameters

array $element: The form element.

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

File

modules/social_features/social_content_block/src/Plugin/Field/FieldWidget/ContentBlockPluginFieldWidget.php, line 178

Class

ContentBlockPluginFieldWidget
Plugin implementation of the 'content_block_plugin_field' widget.

Namespace

Drupal\social_content_block\Plugin\Field\FieldWidget

Code

public static function validateElement(array $element, FormStateInterface $form_state) {
  $value = $form_state
    ->getValue([
    'field_plugin_field',
    0,
    $form_state
      ->getValue([
      'field_plugin_id',
      0,
      'value',
    ]),
  ]);
  if ($value === 'all') {
    $form_state
      ->setValueForElement($element, NULL);
  }
  else {
    $form_state
      ->setValueForElement($element, [
      'value' => $value,
    ]);
  }
}