{"id":14966427,"url":"https://github.com/yiisoft/form-model","last_synced_at":"2026-04-01T21:17:04.968Z","repository":{"id":210241887,"uuid":"726060312","full_name":"yiisoft/form-model","owner":"yiisoft","description":"Provides a base for form models and helps to fill, validate and display them.","archived":false,"fork":false,"pushed_at":"2026-03-21T05:47:58.000Z","size":181,"stargazers_count":16,"open_issues_count":7,"forks_count":6,"subscribers_count":14,"default_branch":"master","last_synced_at":"2026-03-21T21:36:13.702Z","etag":null,"topics":["form","forms","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"],"polar":"yiisoft"}},"created_at":"2023-12-01T13:00:19.000Z","updated_at":"2026-03-21T05:47:59.000Z","dependencies_parsed_at":"2024-01-10T06:45:29.669Z","dependency_job_id":"50462b90-966c-401a-8d21-4fd9ad6ae060","html_url":"https://github.com/yiisoft/form-model","commit_stats":{"total_commits":56,"total_committers":8,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"f5487af1b4421f988edd80d52f26b1d485061fdb"},"previous_names":["yiisoft/form-model"],"tags_count":5,"template":false,"template_full_name":"yiisoft/package-template","purl":"pkg:github/yiisoft/form-model","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fform-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fform-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fform-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fform-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/form-model/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fform-model/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form","forms","yii3"],"created_at":"2024-09-24T13:36:22.218Z","updated_at":"2026-04-01T21:17:04.949Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft","https://polar.sh/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Form Model\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/form-model/v)](https://packagist.org/packages/yiisoft/form-model)\n[![Total Downloads](https://poser.pugx.org/yiisoft/form-model/downloads)](https://packagist.org/packages/yiisoft/form-model)\n[![Build status](https://github.com/yiisoft/form-model/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/form-model/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/form-model/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/form-model)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fform-model%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/form-model/master)\n[![static analysis](https://github.com/yiisoft/form-model/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/form-model/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/form-model/coverage.svg)](https://shepherd.dev/github/yiisoft/form-model)\n[![psalm-level](https://shepherd.dev/github/yiisoft/form-model/level.svg)](https://shepherd.dev/github/yiisoft/form-model)\n\nThe package provides a base for form models and helps to fill them with data, validate them and display them.\n\n## Requirements\n\n- PHP 8.1 - 8.5.\n- `mbstring` PHP extension.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/form-model\n```\n\n## General usage\n\nDefine a [form model](docs/guide/en/form-model.md):\n\n```php\nuse Yiisoft\\FormModel\\Attribute\\Safe;\nuse Yiisoft\\FormModel\\FormModel;\nuse Yiisoft\\Validator\\Rule\\Email;\nuse Yiisoft\\Validator\\Rule\\Length;\nuse Yiisoft\\Validator\\Rule\\Required;\n\nfinal class LoginForm extends FormModel\n{\n    #[Label('Your login')]\n    #[Required]\n    #[Length(min: 4, max: 40, skipOnEmpty: true)]\n    #[Email(skipOnEmpty: true)]\n    private ?string $login = null;\n\n    #[Label('Your password')]\n    #[Required]\n    #[Length(min: 8, skipOnEmpty: true)]\n    private ?string $password = null;\n\n    #[Label('Remember me for 1 week')]\n    #[Safe]\n    private bool $rememberMe = false;\n}\n```\n\nFill it with data and validate using [form hydrator](docs/guide/en/form-hydrator.md):\n\n```php\nuse Psr\\Http\\Message\\RequestInterface;\nuse Yiisoft\\FormModel\\FormHydrator;\nuse Yiisoft\\FormModel\\FormModel;\n\nfinal class AuthController \n{\n    public function login(RequestInterface $request, FormHydrator $formHydrator): ResponseInterface\n    {\n        $formModel = new LoginForm();\n        $errors = [];\n        if ($formHydrator-\u003epopulateFromPostAndValidate($formModel, $request)) {\n            $errors = $formModel-\u003egetValidationResult()-\u003egetErrorMessagesIndexedByProperty();\n        }\n        \n        // You can pass $formModel and $errors to the view now.\n    }\n}\n```\n\nDisplay it using [fields](docs/guide/en/displaying-fields.md) in the view:\n\n```php\nuse Yiisoft\\FormModel\\Field;\nuse Yiisoft\\FormModel\\FormModel;\n\necho Field::text($formModel, 'login');\necho Field::password($formModel, 'password');\necho Field::checkbox($formModel, 'rememberMe');\n\n// ...\n```\n\n## Documentation\n\n- [Guide](docs/guide/en/README.md)\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for\nthat. You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Form Model is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fform-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fform-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fform-model/lists"}