Skip to content

Commit

Permalink
ELA-756: Facet checkbox widget with Boolean fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
julien- committed Sep 5, 2023
1 parent b10cad8 commit 0a06618
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Plugin/facets/widget/MultiselectCheckboxWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ public function build(FacetInterface $facet) {
* {@inheritdoc}
*/
public function prepareValueForUrl(FacetInterface $facet, array &$form, FormStateInterface $form_state): array {
$values = $form_state->getValue($facet->id());
// Remove "0" values, unchecked checkboxes.
$values = array_filter($values);
return $values;
$values = array_filter($form_state->getValue($facet->id()), function ($value) {
// Remove 0 (integer) values, that are unchecked checkboxes.
// "0" (string) can be a value (for boolean fields).
return $value !== 0;
});
}

}

0 comments on commit 0a06618

Please sign in to comment.