The getValue() method of the Area class only seems to look at submitted values, not taking default values into account.
Example:
$area = new Area("Test Area", active: true, "test-area_wrapper", checked: false, []);
$this->assertFalse($area->getValue());
$area = new Area("Test Area", active: true, "test-area_wrapper", checked: true, []);
$this->assertTrue($area->getValue());
$area = new Area("Test Area", active: false, "test-area_wrapper", checked: false, []);
$this->assertFalse($area->getValue());
Note: I've added active: and checked: annotations for clarity.
In the first area, its active and the active area's checkbox, which is rendered in the , is false by default (checked: false).
In that case, I would expect $area->getValue() to be false, which is correct.
In the second case, it's an active area with a default value of true. In this case, I would expect $area->getValue() to return true. However, it returns false since the underlying logic calls ValidForm::get($fieldName) which in turn checks against submitted form values, not taking default values in to account.
Is this expected behavior or should this be fixed?
The getValue() method of the Area class only seems to look at submitted values, not taking default values into account.
Example:
Note: I've added
active:andchecked:annotations for clarity.In the first area, its active and the active area's checkbox, which is rendered in the , is false by default (
checked: false).In that case, I would expect
$area->getValue()to befalse, which is correct.In the second case, it's an active area with a default value of
true. In this case, I would expect$area->getValue()to returntrue. However, it returns false since the underlying logic callsValidForm::get($fieldName)which in turn checks against submitted form values, not taking default values in to account.Is this expected behavior or should this be fixed?