{"id":13501124,"url":"https://github.com/angstwad/flask-form-macros","last_synced_at":"2026-01-17T08:19:49.671Z","repository":{"id":19602469,"uuid":"22853313","full_name":"angstwad/flask-form-macros","owner":"angstwad","description":"Jinja2/Flask macros used to generate form fields","archived":false,"fork":false,"pushed_at":"2014-08-21T02:19:16.000Z","size":150,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T20:39:17.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angstwad.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}},"created_at":"2014-08-11T20:15:34.000Z","updated_at":"2018-09-27T14:40:38.000Z","dependencies_parsed_at":"2022-09-18T23:03:04.461Z","dependency_job_id":null,"html_url":"https://github.com/angstwad/flask-form-macros","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angstwad%2Fflask-form-macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angstwad%2Fflask-form-macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angstwad%2Fflask-form-macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angstwad%2Fflask-form-macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angstwad","download_url":"https://codeload.github.com/angstwad/flask-form-macros/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162092,"owners_count":20733351,"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","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":"2024-07-31T22:01:26.441Z","updated_at":"2026-01-17T08:19:49.665Z","avatar_url":"https://github.com/angstwad.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"flask-form-macros\n=================\n\n## What?\n\nFlask macros are Jinja2 macros that are called like functions.  These macros create form field boilerplate, and were intended to replace my use of WTForms in my projects.\n\n## Use\n\nFirst add this template filter into your application:\n```\n@app.template_filter()\ndef slugify(string):\n    return string.lower().replace(' ', '_')\n```\n\nPlace `form_field_macros.html` in your Flask templates folder, and import:\n\n```\n{% import \"form_field_macros.html\" as fields %}\n``` \n\nThen call:\n\n```\n{{ fields.TextField('My Field') }}\n```\n\nThis will render a field that looks like this:\n\n```\n\u003cdiv\u003e\n    \u003clabel\u003eMy Field: \u003c/label\u003e\n    \u003cinput type=\"text\"\n           id=\"my_field\"\n           name=\"my_field\"\n           class=\"\"\n           size=\"20\"\n           \n    \u003e\n\u003c/div\u003e\n````\n\n**Horizontal forms** are for Bootstrap-compatible horizontal forms.  You'll of course need to have a properly sourced Bootstrap project for this to work. These macros are only meant to support Bootstrap 2.3.2.\n\n```\n{{ fields.TextField('My Field', horizontal=True) }}\n```\n\n```\n \u003cdiv class=\"control-group\"\u003e\n    \u003clabel class=\"control-label\"\u003eMy Field: \u003c/label\u003e\n    \u003cdiv class=\"controls\"\u003e\n            \u003cinput type=\"text\"\n                   id=\"my_field\"\n                   name=\"my_field\"\n                   class=\"\"\n                   size=\"20\"\n            \u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## Okay, now what?\n\nEssentially, you pass in either a) the macro arguments as specified in the macro signature, or b) you pass in HTML attributes as booleans or key/value pairs. So, if you want to have an HTML5 \"email\" field, with a value set, that is required:\n\n```\n{{ fields.Field('Email Field', type=\"email\", value=\"Put a value here\", required=True) }}\n```\n\n## License\n\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangstwad%2Fflask-form-macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangstwad%2Fflask-form-macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangstwad%2Fflask-form-macros/lists"}