{"id":15255641,"url":"https://github.com/e0ipso/schema-forms-php","last_synced_at":"2025-07-24T14:33:07.844Z","repository":{"id":46784232,"uuid":"198769635","full_name":"e0ipso/schema-forms-php","owner":"e0ipso","description":"Creates form definitions from JSON Schema property definitions and display configuration.","archived":false,"fork":false,"pushed_at":"2024-06-05T10:37:38.000Z","size":296,"stargazers_count":9,"open_issues_count":9,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-23T12:21:51.640Z","etag":null,"topics":["drupal","drupal-8","forms","json-schema","php","schema"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/e0ipso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2019-07-25T06:18:16.000Z","updated_at":"2025-04-11T09:22:44.000Z","dependencies_parsed_at":"2025-02-20T08:42:18.566Z","dependency_job_id":null,"html_url":"https://github.com/e0ipso/schema-forms-php","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/e0ipso/schema-forms-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fschema-forms-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fschema-forms-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fschema-forms-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fschema-forms-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e0ipso","download_url":"https://codeload.github.com/e0ipso/schema-forms-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fschema-forms-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266855744,"owners_count":23995543,"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-07-24T02:00:09.469Z","response_time":99,"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":["drupal","drupal-8","forms","json-schema","php","schema"],"created_at":"2024-09-30T00:06:53.074Z","updated_at":"2025-07-24T14:33:07.796Z","avatar_url":"https://github.com/e0ipso.png","language":"PHP","readme":"# Schema Forms\nSchema forms is a project that aims to generate form structures for the different PHP frameworks based on the data definitions in JSON Schema.\n\nFrameworks supported:\n  - Drupal.\n\n# Usage\nGiven the following JSON Schema defining the different properties of a user object.\n```json\n{\n  \"title\": \"A registration form\",\n  \"description\": \"A simple form example.\",\n  \"type\": \"object\",\n  \"required\": [\n    \"firstName\",\n    \"lastName\"\n  ],\n  \"properties\": {\n    \"firstName\": {\n      \"type\": \"string\",\n      \"title\": \"First name\",\n      \"default\": \"Chuck\"\n    },\n    \"lastName\": {\n      \"type\": \"string\",\n      \"title\": \"Last name\"\n    },\n    \"age\": {\n      \"type\": \"integer\",\n      \"title\": \"Age\",\n      \"description\": \"(earthian year)\"\n    },\n    \"bio\": {\n      \"type\": \"string\",\n      \"title\": \"Bio\"\n    },\n    \"password\": {\n      \"type\": \"string\",\n      \"title\": \"Password\",\n      \"minLength\": 3,\n      \"description\": \"The key to get in.\"\n    },\n    \"telephone\": {\n      \"type\": \"string\",\n      \"title\": \"Telephone\",\n      \"minLength\": 10\n    }\n  }\n```\n\nAnd the following UI JSON Schema refining the form generation process:\n```json\n{\n  \"firstName\": {\n    \"ui:autofocus\": true,\n    \"ui:emptyValue\": \"\"\n  },\n  \"age\": {\n    \"ui:widget\": \"updown\",\n    \"ui:title\": \"Age of person\"\n  },\n  \"bio\": {\n    \"ui:widget\": \"textarea\"\n  },\n  \"password\": {\n    \"ui:widget\": \"password\",\n    \"ui:help\": \"Hint: Make it strong!\"\n  },\n  \"date\": {\n    \"ui:widget\": \"alt-datetime\"\n  },\n  \"telephone\": {\n    \"ui:options\": {\n      \"inputType\": \"tel\"\n    }\n  }\n}\n```\n\nExecute this PHP code:\n```php\nuse SchemaForms\\Drupal\\FormGeneratorDrupal;\n$generator = new FormGeneratorDrupal();\n$context = new Context(['ui_hints =\u003e $ui_schema_data]);\n$actual_form = $generator-\u003etransform($schema_data, $context);\n// It generates the following Drupal Form API form:\n[\n  'firstName' =\u003e [\n    '#type' =\u003e 'textfield',\n    '#title' =\u003e 'First name',\n    '#required' =\u003e TRUE,\n  ],\n  'lastName' =\u003e [\n    '#type' =\u003e 'textfield',\n    '#title' =\u003e 'Last name',\n    '#required' =\u003e TRUE,\n  ],\n  'age' =\u003e [\n    '#type' =\u003e 'number',\n    '#title' =\u003e 'Age of person',\n    '#description' =\u003e '(earthian year)'\n  ],\n  'bio' =\u003e [\n    '#type' =\u003e 'textarea',\n    '#title' =\u003e 'Bio',\n  ],\n  'password' =\u003e [\n    '#type' =\u003e 'password',\n    '#title' =\u003e 'Password',\n    '#description' =\u003e 'Hint: Make it strong!'\n  ],\n  'telephone' =\u003e [\n    '#type' =\u003e 'telephone',\n    '#title' =\u003e 'Telephone',\n  ],\n];\n```\n\n### UI Schema Data\nBased on the shape of the data described by the JSON Schema, this library can generate a form.\nHowever, there are multiple ways to generate a form for the same shape of data. The UI schema data\nallows you to control the form elements and inputs that will collect the data in the appropriate way.\n\nSupported UI controls are:\n\n  - `$ui_form_data['ui:title']`\n\n    Controls the label associated to the input element. Defaults to the element's `title` property in the JSON Schema. \n  - `$ui_form_data['ui:help']`\n\n    Adds a hint to the input element. Defaults to the element's `description` property in the JSON Schema.\n  - `$ui_form_data['ui:placeholder']`\n\n    Adds a placeholder text to the input.\n  - `$ui_form_data['ui:widget']`\n\n    Lets you use al alternative input element. For instance, it lets you use `\u003cselect\u003e` instead of\n    `\u003cinput type=\"radio\"\u003e`, or use `\u003cinput type=\"hidden\"\u003e`, among others.\n  - `$ui_form_data['ui:enabled']`\n\n    If 0 the form element will be rendered as non-interactive.\n  - `$ui_form_data['ui:visible']`\n\n    If 0 the form element will not be rendered.\n  - `$ui_form_data['ui:enum']`\n\n    Lets you define how the options for selects and radios are populated. By default, the enum information in the schema\n    defines the options. This might not be enough, or even possible.\n    - `$ui_form_data['ui:enum']['labels']['mappings']`\n\n    An object defining the label for each key. Ex: `{\"uuid1\": \"Super duper product\"}`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe0ipso%2Fschema-forms-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe0ipso%2Fschema-forms-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe0ipso%2Fschema-forms-php/lists"}