{"id":31859500,"url":"https://github.com/python-ellar/ellar-form","last_synced_at":"2025-10-12T15:26:05.453Z","repository":{"id":261865803,"uuid":"860636252","full_name":"python-ellar/ellar-form","owner":"python-ellar","description":"Traditional Form package integrated with Pydantic models for an Ellar python web framework","archived":false,"fork":false,"pushed_at":"2025-10-04T07:03:41.000Z","size":202,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T09:07:40.501Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-ellar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"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}},"created_at":"2024-09-20T20:20:19.000Z","updated_at":"2025-10-04T07:03:38.000Z","dependencies_parsed_at":"2024-11-08T22:24:28.997Z","dependency_job_id":"72eb17af-a69e-407c-a9ba-1a463e0cbedc","html_url":"https://github.com/python-ellar/ellar-form","commit_stats":null,"previous_names":["python-ellar/ellar-form"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/python-ellar/ellar-form","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-ellar%2Fellar-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-ellar%2Fellar-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-ellar%2Fellar-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-ellar%2Fellar-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-ellar","download_url":"https://codeload.github.com/python-ellar/ellar-form/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-ellar%2Fellar-form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011850,"owners_count":26085004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-10-12T15:26:03.197Z","updated_at":"2025-10-12T15:26:05.441Z","avatar_url":"https://github.com/python-ellar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"#\" target=\"blank\"\u003e\u003cimg src=\"docs/img/EllarLogoIconOnly.png\" width=\"200\" alt=\"Ellar Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eTraditional Form package integrated with Pydantic models for an Ellar python web framework\u003c/p\u003e\n\n![Test](https://github.com/python-ellar/ellar-form/actions/workflows/test_full.yml/badge.svg)\n![Coverage](https://img.shields.io/codecov/c/github/python-ellar/ellar-form)\n[![PyPI version](https://badge.fury.io/py/ellar-form.svg)](https://badge.fury.io/py/ellar-form)\n[![PyPI version](https://img.shields.io/pypi/v/ellar-form.svg)](https://pypi.python.org/pypi/ellar-form)\n[![PyPI version](https://img.shields.io/pypi/pyversions/ellar-form.svg)](https://pypi.python.org/pypi/ellar-form)\n\n\n## Introduction\n\nEllar-Form is a powerful and flexible form design package that seamlessly integrates with Pydantic models and the Ellar web framework. It comes with Pydantic field validation and can easily be rendered to HTML.\n\nKey features of Ellar-Form include:\n1. **Pydantic Integration**: Leverages Pydantic models for form field definitions and validation.\n2. **Ellar Compatibility**: Designed to work seamlessly with Ellar's routing and request handling system.\n3. **Automatic Form Generation**: Can automatically generate form fields from Pydantic models.\n4. **Flexible Rendering**: Supports custom HTML templates for form field rendering.\n\nEllar-Form bridges the gap between Ellar web framework capabilities \nand the need for traditional form handling in web applications.\n\n## Installation\nTo install Ellar-Form, simply use pip:\n\n```bash\npip install ellar-form\n```\n\n## Usage\nThe following example demonstrates how to use Ellar-Form to handle form data in an Ellar application:\n### ZForm Example\nZForm provides a convenient way to define and handle forms in your Ellar applications. Here's an example of how to use ZForm:\n\n```python\nfrom pydantic import BaseModel, EmailStr\nfrom ellar.common import ModuleRouter, render_template\nfrom zform import ZForm\n\nclass UserFormModel(BaseModel):\n    password: str\n    email: EmailStr\n\nrouter = ModuleRouter('/')\n\n@router.http_route(\"login\", methods=[\"post\", \"get\"])\ndef login(form: ZForm[UserFormModel]):\n    if form.validate():\n        return render_template(\"successful.html\")\n\n    return render_template(\"login.html\", form=form)\n```\n\nIn this example, we define a UserFormModel using Pydantic, which automatically creates corresponding form fields. The ZForm[UserFormModel] parameter in the route handler creates a form instance that can be validated and processed.\n\n### FormManager Example\nFor more control over form processing, you can use the FormManager directly:\n\n```python\nfrom ellar.common import ModuleRouter, IExecutionContext, render_template\nfrom zform import FormManager\n\nrouter = ModuleRouter('/')\n\n@router.http_route(\"login/another\", methods=[\"post\", \"get\"])\nasync def login_another(ctx: IExecutionContext):\n    form = FormManager.from_schema(UserFormModel,ctx=ctx)\n    \n    if await form.validate():\n        return render_template(\"successful.html\")\n\n    return render_template(\"login.html\", form=form)\n```\n\nIn this example, we define a UserFormModel using Pydantic, which automatically creates corresponding form fields. The ZForm[UserFormModel] parameter in the route handler creates a form instance that can be validated and processed.\n\n### Form Templates Rendering\nEllar-Form provides customizable HTML templates for rendering form fields. Here's an example of a custom form template:\n\n```html\n \u003cform method=\"post\" action=\"/form\"\u003e\n        \u003ctable\u003e\n            {% for field in form %}\n                \u003ctr\u003e\n                    \u003cth\u003e{{ field.label }}\u003c/th\u003e\n                    \u003ctd\u003e{{ field }}\u003c/td\u003e\n                \u003c/tr\u003e\n            {% endfor %}\n        \u003c/table\u003e\n        \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n    \u003c/form\u003e\n```\n\nWhen there is an error in the form, the template will render the error messages:\n\n```html\n\u003cform method=\"post\" action=\"/form\"\u003e\n    \u003ctable\u003e\n        {% for field in form %}\n            \u003ctr\u003e\n                \u003cth\u003e{{ field.label }}\u003c/th\u003e\n                \u003ctd\u003e{{ field }}\u003c/td\u003e\n                {% if field.errors %}\n                    \u003ctd class=\"error\"\u003e{{ field.errors[0] }}\u003c/td\u003e\n                {% endif %}\n            \u003c/tr\u003e\n        {% endfor %}\n    \u003c/table\u003e\n    \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\n\n## Contributing\nWe welcome contributions to Ellar-Form! If you have suggestions or improvements, please open an issue or submit a pull request.\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-ellar%2Fellar-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-ellar%2Fellar-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-ellar%2Fellar-form/lists"}