From a380dacf42f421abf9c50ff1abc40e66dc2df537 Mon Sep 17 00:00:00 2001 From: Thibeau Fuhrer Date: Tue, 18 Aug 2026 16:19:36 +0200 Subject: [PATCH] [FIX] #48017 UI: `Field\Group::withValue()` null support (#11953) This ensures that `withValue()` can be called on nested sub inputs without calling respective `isClientSideValueOk()` methods. Unfortunately this couples the `isClientSideValueOk()` internals to `withValue()` internals, which is suboptimal. We should improve how inputs handle `null` (maybe using `Refinery\Transformation`) and revisit this at a later point. --- .../Implementation/Component/Input/Group.php | 4 +++ .../Component/Input/Field/GroupInputTest.php | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/components/ILIAS/UI/src/Implementation/Component/Input/Group.php b/components/ILIAS/UI/src/Implementation/Component/Input/Group.php index cf0af1b206e7..ad13272feb76 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Input/Group.php +++ b/components/ILIAS/UI/src/Implementation/Component/Input/Group.php @@ -142,6 +142,10 @@ protected function _isClientSideValueOk($value): bool if (!array_key_exists($key, $value)) { return false; } + /** this is currently entangled to {@see Input::withValue()} */ + if (null === $value[$key]) { + continue; + } if (!$input->isClientSideValueOk($value[$key])) { return false; } diff --git a/components/ILIAS/UI/tests/Component/Input/Field/GroupInputTest.php b/components/ILIAS/UI/tests/Component/Input/Field/GroupInputTest.php index 4e88da38b374..eb2902df69bf 100755 --- a/components/ILIAS/UI/tests/Component/Input/Field/GroupInputTest.php +++ b/components/ILIAS/UI/tests/Component/Input/Field/GroupInputTest.php @@ -171,6 +171,35 @@ public function testGroupForwardsValuesOnWithValue(): void $this->assertNotSame($this->group, $new_group); } + public function testGroupForwardsNullWithoutValidationOnWithValue(): void + { + $this->child1 + ->expects($this->once()) + ->method("withValue") + ->with(1) + ->willReturn($this->child2); + $this->child1 + ->expects($this->once()) + ->method("isClientSideValueOk") + ->with(1) + ->willReturn(true); + $this->child2 + ->expects($this->once()) + ->method("withValue") + ->with(null) + ->willReturn($this->child1); + $this->child2 + ->expects($this->never()) + ->method("isClientSideValueOk") + ->with(null) + ->willReturn(true); + + $new_group = $this->group->withValue([1, null]); + + $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs()); + $this->assertNotSame($this->group, $new_group); + } + public function testWithValuePreservesKeys(): void { $this->assertNotSame($this->child1, $this->child2);