{"id":14987464,"url":"https://github.com/tattersoftware/codeigniter4-forms","last_synced_at":"2025-04-12T00:15:30.132Z","repository":{"id":35670345,"uuid":"214189361","full_name":"tattersoftware/codeigniter4-forms","owner":"tattersoftware","description":"RESTful AJAX forms for CodeIgniter 4","archived":false,"fork":false,"pushed_at":"2024-01-17T20:17:21.000Z","size":125,"stargazers_count":7,"open_issues_count":4,"forks_count":7,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-12T00:15:22.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/tattersoftware.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-10T13:24:08.000Z","updated_at":"2024-08-15T18:51:49.000Z","dependencies_parsed_at":"2024-09-25T00:32:20.448Z","dependency_job_id":null,"html_url":"https://github.com/tattersoftware/codeigniter4-forms","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":"0.32432432432432434","last_synced_commit":"76efa679d473cd07216183e58d8911bc6c1c98ef"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tattersoftware","download_url":"https://codeload.github.com/tattersoftware/codeigniter4-forms/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497818,"owners_count":21113984,"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-09-24T14:14:39.236Z","updated_at":"2025-04-12T00:15:30.103Z","avatar_url":"https://github.com/tattersoftware.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tatter\\Forms\nRESTful AJAX forms for CodeIgniter 4\n\n[![](https://github.com/tattersoftware/codeigniter4-forms/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-forms/actions/workflows/phpunit.yml)\n[![](https://github.com/tattersoftware/codeigniter4-forms/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-forms/actions/workflows/phpstan.yml)\n[![](https://github.com/tattersoftware/codeigniter4-forms/workflows/Deptrac/badge.svg)](https://github.com/tattersoftware/codeigniter4-forms/actions/workflows/deptrac.yml)\n[![Coverage Status](https://coveralls.io/repos/github/tattersoftware/codeigniter4-forms/badge.svg?branch=develop)](https://coveralls.io/github/tattersoftware/codeigniter4-forms?branch=develop)\n\n## Quick Start\n\n1. Install with Composer: `\u003e composer require tatter/forms`\n2. Publish the assets: `\u003e php spark assets:publish`\n3. Add the JavaScript to your views\n\n## Features\n\nProvides Resource and Presenter controller templates and corresponding JavaScript for using\nAJAX forms with CodeIgniter 4's native RESTful implementation.\n\n## Installation\n\nInstall easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities\nand always be up-to-date:\n```shell\n\u003e composer require tatter/forms\n```\n\nOr, install manually by downloading the source files and adding the directory to\n**app/Config/Autoload.php**.\n\nAfter installation you will need to copy or publish the required assets to your\n**public/** folder. If you want to automate this process check out the\n[Assets Library](https://github.com/tattersoftware/codeigniter4-assets).\n\nFinally, notify your view/layout of your intention to use the JavaScript for your forms\n(your paths may vary):\n```html\n\u003cscript src=\"assets/vendor/forms/forms.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\tvar baseUrl = \"\u003c?= base_url() ?\u003e\";\n\tvar siteUrl = \"\u003c?= site_url() ?\u003e\";\n\tvar apiUrl  = \"\u003c?= site_url(config('forms')-\u003eapiUrl) ?\u003e\";\n\u003c/script\u003e\n```\n\n## Configuration (optional)\n\nThe library's default behavior can be overridden or augment by its config file. Copy\n**examples/Forms.php** to **app/Config/Forms.php** and follow the instructions in the\ncomments. If no config file is found the library will use its defaults.\n\n## Usage\n\n***Note:*** Please consider this module to be modular itself - you need not use every piece!*\n*Treat portions of the code that you do not use as examples for how to implement this in your own app.*\n\nAfter the initial installation there are a few pieces to implement. **Forms** will run\nCRUD-style operations for you by interfacing views with the `ResourcePresenter` or\n`ResourceController` depending on the method of interaction (i.e. page load versus AJAX).\nNot surprisingly, you will need some **Views** and two **Controllers** per resource.\n\n### Naming\n\n**Forms** interacts with each resource route and controller through that resource's name.\nIf you are creating a game, your resource names might be *hero(es)*, *level(s)*, *reward(s)*,\netc. The naming convention is important for autoloading resources and their endpoints. By\ndefault, **Forms** will use the name of the model associated with your resource. So a URL of\n`heroes/new` would route to the `HeroController` which uses `HeroModel` and the whole\nresource would be dubbed \"hero\" off that model.\n\nIf you need to set your own names, do so with your model's `$name` property:\n```php\nclass HeroModel extends \\CodeIgniter\\Model\n{\n\tpublic $name = 'superhero';\n\t...\n```\n\n### Views\n\nIf you choose to use the built-in Controllers they expect the following views to be available\nfor each resource (where {names} is the plural of your resource name):\n\n* **Views/{names}/new** - Prompt to create a new object, wrapping **{names}/form**\n* **Views/{names}/index** - List of all (or filtered) objects, wrapping **{names}/list**\n* **Views/{names}/show** - Details of a single object, wrapping **{names}/display**\n* **Views/{names}/edit** - Prompt to change an object, wrapping **{names}/form**\n* **Views/{names}/remove** - Prompt to remove an object, wrapping **{names}/display** and **{names}/confirm**\n* **Views/{names}/list** - Patial view; a list of objects\n* **Views/{names}/form** - Patial view; the form used for new and edit\n* **Views/{names}/display** - Partial view; a displayable verison of one object\n* **Views/{names}/confirm** - Partial view; prompt to delete an object\n\nAs you can see **Forms** expects some views that are part of a full page load layout and\nsome that can be injected into an existing page via AJAX (e.g. in a modal). See\n[examples](examples/Views/) for a full set of example view files (note: these are presented\n\"as is\" and may not always be the best solution for all use cases).\n\n### Controllers\n\nIn addition to the views, you will need two controllers for each resource:\n* **Controllers/{names}.php** - Your presenter for page loads, extends `Tatter\\Forms\\Controllers\\ResourcePresenter`\n* **Controllers/API/{names}.php** - Your controller for AJAX calls, extends `Tatter\\Forms\\Controllers\\ResourceController`\n\nAs with other framework RESTful controllers, your controllers set their model via the\n`$modelName` property:\n```php\n\u003c?php\n\nnamespace App\\Controllers;\n\nuse App\\Models\\HeroModel;\nuse Tatter\\Forms\\Controllers\\ResourcePresenter;\n\nclass Heroes extends ResourcePresenter\n{\t\n\tprotected $modelName = HeroModel::class;\n\t...\n```\n\nYour resource controller can take an additional property, `$format`, to specify response\nformat (**Forms** currently only supports JSON):\n```php\n\u003c?php\n\nnamespace App\\Controllers\\API;\n\nuse App\\Models\\HeroModel;\nuse Tatter\\Forms\\Controllers\\ResourceController;\n\nclass Heroes extends ResourceController\n{\t\n\tprotected $modelName = HeroModel::class;\n\tprotected $format    = 'json';\n\t...\n```\n\nSee [RESTful Resource Handling](https://codeigniter.com/user_guide/incoming/restful.html)\nin the CodeIgniter 4 User Guide for more info on using resource controllers.\n\n### Routes\n\nYou will need to add routes to both controllers for every resource:\n```\n$routes-\u003epresenter('heroes');\n$routes-\u003eresource('api/heroes', ['controller' =\u003e 'App\\Controllers\\API\\Heroes']);\n\n$routes-\u003epresenter('rewards');\n$routes-\u003eresource('api/rewards', ['controller' =\u003e 'App\\Controllers\\API\\Rewards']);\n```\n\nBy default your resource controller routes will all be prefixed \"api/\", but you can change\nthis in your config file.\n\n### JavaScript\n\n**Forms** includes a light set of JavaScript commands for passing data between your views\nand controllers and auto-handling AJAX requests. If you want a more complete set of functions,\nor fully automated object handler you will want to include your own third-party tools and\nimplement them in your view files.\n\n#### jQuery\n\nThis package uses jQuery (not included). Future versions will drop jQuery in favor of\nnative JavaScript (via [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattersoftware%2Fcodeigniter4-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftattersoftware%2Fcodeigniter4-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattersoftware%2Fcodeigniter4-forms/lists"}