{"id":31863862,"url":"https://github.com/sujancse/laraform","last_synced_at":"2025-10-12T18:57:46.730Z","repository":{"id":57061143,"uuid":"127273926","full_name":"sujancse/laraform","owner":"sujancse","description":"YAML, JSON to html form with validation for laravel","archived":false,"fork":false,"pushed_at":"2021-09-28T15:52:58.000Z","size":19,"stargazers_count":46,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T05:32:28.806Z","etag":null,"topics":["form-builder","html-form","json","json-to-form","laravel","yaml","yaml-to-form"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sujancse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-29T10:09:52.000Z","updated_at":"2025-02-11T21:33:57.000Z","dependencies_parsed_at":"2022-08-24T14:53:43.050Z","dependency_job_id":null,"html_url":"https://github.com/sujancse/laraform","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sujancse/laraform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujancse%2Flaraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujancse%2Flaraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujancse%2Flaraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujancse%2Flaraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sujancse","download_url":"https://codeload.github.com/sujancse/laraform/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujancse%2Flaraform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279012519,"owners_count":26085135,"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":["form-builder","html-form","json","json-to-form","laravel","yaml","yaml-to-form"],"created_at":"2025-10-12T18:57:44.700Z","updated_at":"2025-10-12T18:57:46.725Z","avatar_url":"https://github.com/sujancse.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YAML, JSON to html form with validation for laravel\nDeveloping rapid forms from YAML and JSON, when large number of input fields will be \nrequired as well as frequent addition and deduction of form fields.\n\n## Installation\n```\ncomposer require \"sujan/laraform\"\n```\n\nAs `sujan/laraform` package is based on `laravelcollective/html` you have to add your new \nprovider to the providers array of config/app.php:\n\n```\n'providers' =\u003e [\n    // ...\n    Sujan\\LaraForm\\ServiceProvider::class,\n    Collective\\Html\\HtmlServiceProvider::class,\n    // ...\n],\n```\n\nFinally, add two class aliases to the aliases array of config/app.php:\n\n```\n'aliases' =\u003e [\n    // ...\n    'Form' =\u003e Collective\\Html\\FormFacade::class,\n    'Html' =\u003e Collective\\Html\\HtmlFacade::class,\n    // ...\n],\n```\n\nThen run the command\n```\nphp artisan vendor:publish\n```\nIt will give you a `laraform.css` file in `/css/laraform.css`\n\nThen add `laraform.css` to your master template like \n```\n\u003clink rel=\"stylesheet\" href=\"{{ asset('css/laraform.css') }}\"\u003e\n```\n\n## Usage\nThis package has multi purpose usage. You will get all the facilities of `Laravel Collective` \nas well as facilities of `sujan/laraform` package. We developed this package based on real life scenario.\n\n### Scenario 1\nSay you have to develop a key value store where all of your application settings will reside. \nThe kick here is to add more and more new keys when needed but no code modification will be needed. \nThen this is the right package for you. All you have to do is to write a YAML or JSON file for your form.\n\n### Scenario 2\nLet's assume the values of your settings will come as a nested object and you have to make a form for \nthe object then this package is a good choice. It will build the form for you within a few minutes all \nyou have to do is write the JSON or YAML file based on the JSON object. \n\n## How to Use\n\nUse it inside form tag in your form like \n```\n{{ Form::yaml(\"path/to/file.yml\") }}\n{{ Form::json(\"path/to/file.json\") }}\n```\n\nLaraform support input types `text`, `email`, `password`, `number`, `hidden`, `date`, `file`, `textarea`, `checkbox`, `select`,\n`radio`, `checkboxlist`, `section`;\n\n### Example 1\nLet's say you have a `users` table and a `usersmeta` table. \nIn `users` table you will save `name`,`email`, `password` and in `usersmeta` table you want to save \n`date_of_birth`, `color`, `gender`, `address`, `favourites`, `profile_pic`. \nYour `yaml` and `json` file will be like below. Where `usermeta` is relation name.\nOur package will parse the form for you.\n\n### Sample YAML for Example 1\n```\nfields:\n    name:\n      label: Name\n      type: text\n      span: left\n      \n    email:\n      label: Email\n      type: email\n      span: right\n      \n    password:\n      label: Password\n      type: password\n      span: left\n      \n    password_confirmation:\n      label: Confirm Password\n      type: password\n      span: right\n      \n    metadata:\n      label: User Meta\n      type: section\n      \n    usermeta[date_of_birth]:\n      label: Date of Birth\n      type: date\n      span: left\n      \n    usermeta[color]:\n      label: Choose Color\n      type: select\n      span: right\n      options:\n        \"\": Choose Color\n        red: Red\n        green: Green\n        blue: Blue\n        \n    usermeta[gender]:\n      label: Gender\n      type: radio\n      span: left\n      options:\n        male: Male\n        female: Female\n        other: Other\n        \n    usermeta[favourites][]:\n      label: Favourites\n      type: checkboxlist\n      span: right\n      options:\n        cake: Cake\n        apple: Apple\n        mango: Mango\n        \n    usermeta[address]:\n      label: Address\n      type: textarea\n      \n    usermeta[profile_pic]:\n      label: Upload profile picture\n      type: file\n```\n\n### Sample JSON for Example 1\n```\n{\n  \"fields\": {\n    \"name\": {\n      \"label\": \"Name\",\n      \"type\": \"text\",\n      \"span\": \"left\"\n    },\n    \"email\": {\n      \"label\": \"Email\",\n      \"type\": \"email\",\n      \"span\": \"right\"\n    },\n    \"password\": {\n      \"label\": \"Password\",\n      \"type\": \"password\",\n      \"span\": \"left\"\n    },\n    \"password_confirmation\": {\n      \"label\": \"Confirm Password\",\n      \"type\": \"password\",\n      \"span\": \"right\"\n    },\n    \"metadata\": {\n      \"label\": \"User Meta\",\n      \"type\": \"section\"\n    },\n    \"usermeta[date_of_birth]\": {\n        \"label\": \"Date of Birth\",\n        \"type\": \"date\",\n        \"span\": \"left\"\n    },\n    \"usermeta[color]\": {\n      \"label\": \"Choose Color\",\n      \"type\": \"select\",\n      \"span\": \"right\",\n      \"options\": {\n        \"\": \"Choose Color\",\n        \"red\": \"Red\",\n        \"green\": \"Green\",\n        \"blue\": \"Blue\"\n      }\n    },\n    \"usermeta[gender]\": {\n      \"label\": \"Gender\",\n      \"type\": \"radio\",\n      \"span\": \"left\",\n      \"options\": {\n        \"male\": \"Male\",\n        \"female\": \"Female\",\n        \"other\": \"Other\"\n      }\n    },\n    \"usermeta[favourites][]\": {\n      \"label\": \"Favourites\",\n      \"type\": \"checkboxlist\",\n      \"span\": \"right\",\n      \"options\": {\n        \"cake\": \"Cake\",\n        \"apple\": \"Apple\",\n        \"mango\": \"Mango\"\n      }\n    },\n    \"usermeta[address]\": {\n      \"label\": \"Address\",\n      \"type\": \"textarea\"\n    },\n    \"usermeta[profile_pic]\": {\n      \"label\": \"Upload profile picture\",\n      \"type\": \"file\"\n    }\n  }\n}\n```\n\nHere `span` left, right is used to push the input fields to left and right. \nIf you don’t specify span then the span will be full by default.\n\n### Sample create form\n```\n{{ Form::open(['method' =\u003e 'POST']) }}\n{{ Form::yaml(/path/to/yaml/file) }}\n{{ Form::submit('Submit', ['class' =\u003e 'form-control']) }}\n{{ Form::close() }}\n```\n\n#### Html form of sample YAML and JSON.\n![Sample form](https://i.imgur.com/v1XhZiR.png)\n\n### Form validation rule:\n```\n$this-\u003evalidate($request, [\n    'name' =\u003e 'required',\n    'email' =\u003e 'required',\n    'password' =\u003e 'required|confirmed',\n    'usermeta.gender' =\u003e 'required',\n    'usermeta.favourites' =\u003e 'required',\n    'usermeta.address' =\u003e 'required',\n    'usermeta.date_of_birth' =\u003e 'required',\n    'usermeta.color' =\u003e 'required',\n    'usermeta.profile_pic' =\u003e 'required|mimes:jpg,png',\n],[\n    'usermeta.address.required' =\u003e 'The address field is required.',\n    'usermeta.favourites.required' =\u003e 'The favourites field is required.',\n    'usermeta.date_of_birth.required' =\u003e 'The date of birth field is required.',\n    'usermeta.color.required' =\u003e 'The color field is required.',\n    'usermeta.gender.required' =\u003e 'The gender field is required.',\n    'usermeta.profile_pic.required' =\u003e 'The profile picture field is required.',\n]);\n```\n\n#### Html form of sample YAML and JSON with validation message.\n![Sample form with validation](https://i.imgur.com/MTAzolf.png)\n\nThe YAML and JSON files work for both create and edit page, all you have to do is \nto pass the model instance or JSON object.\n\n#### Sample edit form for the above example.\n```\n{{ Form::model($model, ['method' =\u003e 'POST']) }}\n{{ Form::yaml(/path/to/yaml/file) }}\n{{ Form::submit('Submit', ['class' =\u003e 'form-control']) }}\n{{ Form::close() }}\n```\n\nHere variable `$model` is model instance or JSON object like below.\n\n## Sample JSON object\n```\n{\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\",\n    \"usermeta\": {\n        \"date_of_birth\": \"2018-04-19\",\n        \"color\": \"green\",\n        \"gender\": \"male\",\n        \"favourites\": [\n            \"cake\",\n            \"mango\"\n        ],\n        \"address\": \"No where\"\n    }\n}\n```\n\n### Sample edit form of the above JSON object\n![Sample edit form](https://i.imgur.com/SHhcnJh.png)\n\n### Sample edit form with validation message\n![Sample edit form with validation](https://i.imgur.com/YuQ9Lwy.png)\n\nThe `yaml` and `json` file for the above object will be `#Sample 1`'s two files.\n\n### Form validation\nYou have to use laravel's form validation methodology. \nThe error message handling is included in the package. \nSo you don't have to write code for showing error messages. \nThe message will be shown below the input field marked red.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsujancse%2Flaraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsujancse%2Flaraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsujancse%2Flaraform/lists"}