public static Checkboxes::getCheckedCheckboxes(array $input)
Determines which checkboxes were checked when a form is submitted.
Parameters
array $input: An array returned by the FormAPI for a set of checkboxes.
Return value
array An array of keys that were checked.
File
- core/lib/Drupal/Core/Render/Element/Checkboxes.php, line 134
Class
- Checkboxes
- Provides a form element for a set of checkboxes.
Namespace
Drupal\Core\Render\Element
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 | public static function getCheckedCheckboxes( array $input ) { // Browsers do not include unchecked options in a form submission. The // FormAPI tries to normalize this to keep checkboxes consistent with other // form elements. Checkboxes show up as an array in the form of option_id => // option_id|0, where integer 0 is an unchecked option. // // @see \Drupal\Core\Render\Element\Checkboxes::valueCallback() // @see https://www.w3.org/TR/html401/interact/forms.html#checkbox $checked = array_filter ( $input , function ( $value ) { return $value !== 0; }); return array_keys ( $checked ); } |
Please login to continue.