- Issue created by @larowlan
- First commit to issue fork.
- Merge request !889#3518313: Add e2e tests for boolean checkbox in page data form → (Merged) created by omkar-pd
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Pushed the required fix here.
The nuance is this in
FormBuilder::handleInputElement
// Get the input for the current element. NULL values in the input need // to be explicitly distinguished from missing input. (see below) $input_exists = NULL; $input = NestedArray::getValue($form_state->getUserInput(), $element['#parents'], $input_exists); // For browser-submitted forms, the submitted values do not contain // values for certain elements (empty multiple select, unchecked // checkbox). During initial form processing, we add explicit NULL // values for such elements in FormState::$input. When rebuilding the // form, we can distinguish elements having NULL input from elements // that were not part of the initially submitted form and can therefore // use default values for the latter, if required. Programmatically // submitted forms can submit explicit NULL values when calling // self::submitForm() so we do not modify FormState::$input for them. if (!$input_exists && !$form_state->isRebuilding() && !$form_state->isProgrammed()) { // 👈️👈️👈️👈️👈️👈️👈️ // Add the necessary parent keys to FormState::$input and sets the // element's input value to NULL. NestedArray::setValue($form_state->getUserInput(), $element['#parents'], NULL); $input_exists = TRUE; }
With
\Drupal\experience_builder\ClientDataToEntityConverter::setEntityFields
we're doing a$form_state->setProgrammed()
so that set value never happens. Therefore the old code that was unsetting (or rather filtering out) unticked checkboxes actually needs to be setting them to NULL rather than removing them.With that change in place, the test passes 🙌
- First commit to issue fork.
- 🇺🇸United States bnjmnm Ann Arbor, MI
The MR looks good, but could this be expanded to include a checkbox with a default value unchecked, in addition to the existing one with
['value' => 1],
? -
wim leers →
committed bc8ce91c on 0.x authored by
omkar-pd →
Issue #3518313 by larowlan, omkar-pd, bnjmnm, wim leers, penyaskito,...
-
wim leers →
committed bc8ce91c on 0.x authored by
omkar-pd →
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Looks like this somehow caused consistent failures in
entity-form-field-types-test.cy.js
despite multiple CI runs on this MR being green— see https://git.drupalcode.org/project/experience_builder/-/commit/bc8ce91c5.... -
wim leers →
committed 80a29aaf on 0.x authored by
bnjmnm →
Issue #3518313 by bnjmnm: Update new test to use `/xb/api/…` → `/xb/api/...
-
wim leers →
committed 80a29aaf on 0.x authored by
bnjmnm →