Skip to content

Commit 1809e5d

Browse files
committed
Merge FormView CollectionType fix and CLAUDE.md cleanup
2 parents 3069525 + aa4e49b commit 1809e5d

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ Related: Nuxt module issue `components-web-app/cwa-nuxt-module#224` Bug 2.
580580

581581
**Read side fixed** (commit `2305ad89`): `ComponentPositionNormalizer.normalizeForPageData()` now skips populating the component if the resolved type is not in `componentGroup.allowedComponents`.
582582

583-
**Write side fixed** (pending commit): `ComponentPosition` now stores a `pageDataClass` (FQCN) alongside `pageDataProperty`. `ComponentPositionValidator` validates the pair on every POST/PATCH: (1) `pageDataClass` must be a known API-registered PageData resource; (2) `pageDataProperty` must be a component-typed property on that class; (3) the resolved component type must be in `componentGroup.allowedComponents` if set. Both fields must be set together (entity-level `Assert\Expression` constraint).
583+
**Write side fixed** (committed): `ComponentPosition` now stores a `pageDataClass` (FQCN) alongside `pageDataProperty`. `ComponentPositionValidator` validates the pair on every POST/PATCH: (1) `pageDataClass` must be a known API-registered PageData resource; (2) `pageDataProperty` must be a component-typed property on that class; (3) the resolved component type must be in `componentGroup.allowedComponents` if set. Both fields must be set together (entity-level `Assert\Expression` constraint).
584584

585585
**`CwaFixtureBuilder` updated:** `GroupBuilder.pageDataPosition()` now takes `pageDataClass` as its first argument: `->pageDataPosition(string $pageDataClass, string $propertyName, ?int $sort = null)`.
586586

features/form/form.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ Feature: Form component that defines a form type created in the application
117117
}
118118
"""
119119

120+
Scenario: CollectionType fields expose allow_add, allow_delete and prototype in the form view
121+
Given there is a "nested" form
122+
When I send a "GET" request to the resource "nested_form"
123+
Then the response status code should be 200
124+
And the JSON node "formView.children[0].vars.allow_add" should be true
125+
And the JSON node "formView.children[0].vars.allow_delete" should be true
126+
And the JSON node "formView.children[0].prototype" should exist
127+
And the JSON node "formView.children[1].vars.allow_add" should be true
128+
And the JSON node "formView.children[1].vars.allow_delete" should be true
129+
And the JSON node "formView.children[1].prototype" should exist
130+
120131
# PATCH NESTED
121132

122133
Scenario: I can send a valid field for validation of one of the children in a CollectionType

src/Model/Form/FormView.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class FormView
3232

3333
private const OUTPUT_VARS = [
3434
'action',
35+
'allow_add',
36+
'allow_delete',
3537
'attr',
3638
'block_prefixes',
3739
'checked',
@@ -62,6 +64,9 @@ class FormView
6264
#[Groups(['Form:cwa_resource:read'])]
6365
private DoctrineCollection $children;
6466

67+
#[Groups(['Form:cwa_resource:read'])]
68+
private ?self $prototype = null;
69+
6570
#[Groups(['Form:cwa_resource:read'])]
6671
private bool $rendered;
6772

@@ -91,7 +96,7 @@ private function init(SymfonyFormView $formView, FormInterface $form, bool $chil
9196
$this->addChild($view);
9297
}
9398
if (\array_key_exists('prototype', $formView->vars)) {
94-
$this->addChild($formView->vars['prototype']);
99+
$this->prototype = new self($this->form, $formView->vars['prototype']);
95100
}
96101
}
97102
}
@@ -142,6 +147,11 @@ public function getChildren(): DoctrineCollection
142147
return $this->children;
143148
}
144149

150+
public function getPrototype(): ?self
151+
{
152+
return $this->prototype;
153+
}
154+
145155
public function isRendered(): bool
146156
{
147157
return $this->rendered;

0 commit comments

Comments
 (0)