public static function NodeTooltip::validateNodeBundles in Glossify 8
Validation callback for glossify_node_bundles.
Make the field required if the filter is enabled.
Parameters
array $element: The element being processed.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $complete_form: The complete form structure.
File
- modules/
glossify_node/ src/ Plugin/ Filter/ NodeTooltip.php, line 100
Class
- NodeTooltip
- Filter to find and process found taxonomy terms in the fields value.
Namespace
Drupal\glossify_node\Plugin\FilterCode
public static function validateNodeBundles(array &$element, FormStateInterface $form_state, array &$complete_form) {
$values = $form_state
->getValues();
// Make node_bundles required if the filter is enabled.
if (!empty($values['filters']['glossify_node']['status'])) {
$field_values = array_filter($values['filters']['glossify_node']['settings']['glossify_node_bundles']);
if (empty($field_values)) {
$element['#required'] = TRUE;
$form_state
->setError($element, t('%field is required.', [
'%field' => $element['#title'],
]));
}
}
}