diff --git a/AGENTS.md b/AGENTS.md index 56fa49e..34f42a0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,7 +29,7 @@ Last verified in the Nix shell on PHP 8.5.6 / Node 24.16.0: - `composer test`: 95 tests, 268 assertions. - `composer phpstan`: no errors. - `composer coverage`: PHP line coverage ~97%, threshold `80%`. -- `npm run test:unit`: Jest 608 tests. +- `npm run test:unit`: Jest 615 tests. - `npm run test:coverage`: JavaScript line coverage ~95%, threshold `80%`. - `npm test`: the above plus the Cypress e2e suite, 24 tests. diff --git a/src/Resources/doc/2_3.md b/src/Resources/doc/2_3.md index 6caf9bf..5f05cff 100644 --- a/src/Resources/doc/2_3.md +++ b/src/Resources/doc/2_3.md @@ -48,11 +48,44 @@ init_js_validation(form = null, onLoad = true, wrapped = true) - `form`: By default, all queued forms are processed. Pass a form name or `FormView` instance to process only one form. - `onLoad`: When `true`, validation models are initialized on document ready. - Pass `false` when you want to initialize them yourself. + Pass `false` when you want to initialize them yourself. A model rendered into + a document that already finished loading - a form fragment an application + fetched and injected after the initial load - is initialized right away, + because the document ready event it would otherwise wait for has already been + dispatched. - `wrapped`: When `true`, the generated code is wrapped in a `` tag. -For example, to initialize validation after an Ajax request: +#### Forms loaded after the page + +A form fragment the application fetches and injects - a modal that loads its +form, a step of a wizard, a single page CRUD - carries the `addModel()` call +the bundle rendered with it, and that call initializes the form as soon as it +runs. The default `onLoad` is enough, there is nothing to pass: + +```twig +{{ form(user) }} +{{ init_js_validation(user) }} +``` + +The one thing the application has to take care of is that the call runs at +all. `innerHTML` does not execute a `