forms
Skill4 starsChanged 4 months agoMITView on GitHub
Build and validate input with laminas-form — Form and Fieldset composition, input filters, validators, and safe binding of untrusted request data. Use when the user wants to hydrate a form from an entity and bind validated data back onto the object; the user needs to build a laminas-form with elements, or compose reusable fieldsets, to render and capture user input; the user wants to validate and filter submitted request data against rules before using it, using an input filter. Keywords: laminas, forms, fieldset, input-filter, validation, input.
10 other projects use a version of this.
Adopted by
Most recently taken up by
- Anglesite/anglesite-skillstheir own version, first seen Oct 27, 2026
- VectorLabAU/skillstheir own version, first seen Oct 11, 2026
- trycompai/comptheir own version, first seen Oct 8, 2026
- msrv-tech/skillstheir own version, first seen Oct 2, 2026
- sukirman1901/frontend-experttheir own version, first seen Sep 10, 2026
- mgifford/accessibility-skillstheir own version, first seen Jul 27, 2026
Used with
Projects with it also use navigation.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
igorescodroSkillnavigation
Use when adding a new screen or modifying navigation in the Alkaa project — triggers on tasks like "add a new screen", "navigate to X", "add destination", "wire up navigation", or "create a navigation event". Also triggers when connecting UI actions to routes in NavGraph.
Also in 3 projects that use this
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- trycompai/comp★ 2.1ksame name
- msrv-tech/skills★ 60same name
- mgifford/accessibility-skills★ 48same name
- Anglesite/anglesite-skills★ 15same name
- sukirman1901/frontend-expert★ 9same name
- YepAPI/skills★ 8same name
- moasq/ios-dev-agent★ 4same name
- miovrag/claude-skills★ 1same name
- VectorLabAU/skills★ 1same name
- anipy1/claude-flutter-kit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- strategy-bitrix-d7-incrementalSkill
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- validationSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- redisSkill
- transactionsSkill
- ci-github-actionsSkill
- deployment-strategiesSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 64
Do not reach for the full Form object when a JSON API only needs to validate a payload.
- Very specific: line 65
Do not use this skill for Symfony Form, Laravel form requests, or client-side-only form markup.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- generated: do not edit — source: knowledge/atoms/laminas/forms/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->Laminas Forms
When to use
- The user wants to hydrate a form from an entity and bind validated data back onto the object.
- The user needs to build a laminas-form with elements, or compose reusable fieldsets, to render and capture user input.
- The user wants to validate and filter submitted request data against rules before using it, using an input filter.
When NOT to use
- Do not reach for the full Form object when a JSON API only needs to validate a payload; a standalone input filter is lighter and sufficient.
- Do not use this skill for Symfony Form, Laravel form requests, or client-side-only form markup; the Form/Fieldset/InputFilter API is Laminas specific.
Core guidance
- Read getData only after isValid returns true — Call
setData($request->getPost())thenisValid(), and only readgetData()(filtered, validated values) onceisValid()has returned true. - Keep validation in an input filter, not in the elements — Define validators and filters in an
InputFilter(viagetInputFilterSpecification()on the fieldset or a dedicated input-filter class), not ad hoc in the controller after submission.
Quick recipe
- Extend
Laminas\Form\Form, add each element ininit()with its name and type, and include aCsrfelement for state-changing forms. (verify: The form renders every declared element plus the CSRF token) - Implement
getInputFilterSpecification()returning per-fieldrequired,filters, andvalidatorsentries so submitted data is filtered and checked. (verify: Invalid submissions failisValid()with per-field messages) - In the controller,
bindthe entity, callsetData($request->getPost()), and onisValid()readgetData(); on failure, re-render the form with its messages. (verify: Valid input updates the entity; invalid input re-renders with errors and no 500)
Best practices
- Include a
Csrfelement on any form that mutates state so submission fails validation unless the request carries a valid, unexpired token - Model a cohesive group of fields (an address, a contact) as a
Fieldsetand compose it into forms, rather than repeating the same elements in each form - Set a hydrator on the fieldset and call
$form->bind($entity)before validation so that, on success, filtered values are written straight onto the domain object
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| Writing raw POST data straight onto the entity | Raw request data is unfiltered and unvalidated, so this reintroduces injection and mass-assignment risks the form removes. | Bind the entity to the form with a hydrator and let getData() write only validated values. |
| Echoing submitted values without view-helper escaping | Re-rendering user input verbatim on validation failure opens a reflected XSS hole. | Render fields through formElement/formRow view helpers (which escape), and escape any custom output with escapeHtml. |
| Hand-writing validation in the controller | Duplicated ad hoc validation drifts from the form's rules and misses the filtering the input filter would apply. | Declare all rules in the form's input filter and rely on isValid() as the single validation gate. |
See references/anti-patterns.md.
Common mistakes
- Csrf validation fails after the token TTL or a new session — A Csrf element rejects a submission when its token has expired (default short TTL) or the session was regenerated between render and submit. Fix: Tune the Csrf element
timeout, re-render the form (with a fresh token) on failure, and preserve the session across the render-submit cycle. - Reading getData before isValid runs the filter — Calling
getData()beforeisValid()returns unfiltered, unvalidated values (or throws in strict mode). Fix: Always order the calls as setData -> isValid -> getData, and branch on the boolean result. - Required-by-default inputs reject legitimately empty fields — An input is required by default, so an optional field with no value fails validation until you mark it
requiredfalse withallow_emptytrue. Fix: In the input filter spec, setrequiredto false andallow_emptyto true for genuinely optional inputs.
Version notes
- laminas-form 3 adds elements in init, not the constructor — In laminas-form 3, build form elements inside
init()(called by the form element manager after construction) so factory-created forms have their dependencies ready, rather than adding elements in__construct().
Security
- Treat form input as untrusted until isValid passes — Feed the raw request into the form with
setData(), runisValid(), and consume onlygetData()afterwards; never trust$request->getPost()values directly, and attach aCsrfelement plus escaping in the view layer.
Testing
- Activation and decision behavior are verified in
eval/scenarios/laminas/forms.yaml.
Additional resources
- references/anti-patterns.md
- references/core.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Related: laminas/mvc, php/typed-properties
<!-- graph-fragment: graph/fragments/laminas/forms.yaml -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

