public static function Blocks::validatePluginIds in Block field 8
Validates plugin_ids table select element.
Parameters
array $element: A form element.
\Drupal\Core\Form\FormStateInterface $form_state: The $form_state from complete form.
array $complete_form: Complete parent form.
Return value
array Returns element with validated plugin ids.
File
- src/
Plugin/ block_field/ BlockFieldSelection/ Blocks.php, line 85
Class
- Blocks
- Provides a 'categories' BlockFieldSection.
Namespace
Drupal\block_field\Plugin\block_field\BlockFieldSelectionCode
public static function validatePluginIds(array &$element, FormStateInterface $form_state, array &$complete_form) {
$value = array_filter($element['#value']);
if (array_keys($element['#options']) == array_keys($value)) {
$form_state
->setValueForElement($element, []);
}
else {
$form_state
->setValueForElement($element, $value);
}
return $element;
}