public static function OptionsBase::validateMultipleOptions in YAML Form 8
Form API callback. Remove unchecked options from value array.
File
- src/
Plugin/ YamlFormElement/ OptionsBase.php, line 413
Class
- OptionsBase
- Provides a base 'options' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public static function validateMultipleOptions(array &$element, FormStateInterface $form_state) {
$name = $element['#name'];
$values = $form_state
->getValue($name);
// Filter unchecked/unselected options whose value is 0.
$values = array_filter($values, function ($value) {
return $value !== 0;
});
$values = array_values($values);
$form_state
->setValue($name, $values);
}