{"id":13824851,"url":"https://github.com/dwightwatson/bootstrap-form","last_synced_at":"2025-12-30T04:07:07.273Z","repository":{"id":17399292,"uuid":"20171816","full_name":"dwightwatson/bootstrap-form","owner":"dwightwatson","description":"Bootstrap 3 form builder for Laravel","archived":true,"fork":false,"pushed_at":"2022-06-30T00:43:38.000Z","size":254,"stargazers_count":217,"open_issues_count":21,"forks_count":132,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-30T03:36:21.074Z","etag":null,"topics":["bootstrap","form-builder","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"feyeleanor/GoLightly","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwightwatson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-26T02:36:30.000Z","updated_at":"2024-06-26T08:20:33.000Z","dependencies_parsed_at":"2022-08-09T04:18:51.182Z","dependency_job_id":null,"html_url":"https://github.com/dwightwatson/bootstrap-form","commit_stats":null,"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/dwightwatson/bootstrap-form","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fbootstrap-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fbootstrap-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fbootstrap-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fbootstrap-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwightwatson","download_url":"https://codeload.github.com/dwightwatson/bootstrap-form/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwightwatson%2Fbootstrap-form/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264343731,"owners_count":23593778,"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":["bootstrap","form-builder","laravel","php"],"created_at":"2024-08-04T09:01:10.492Z","updated_at":"2025-12-17T10:34:17.331Z","avatar_url":"https://github.com/dwightwatson.png","language":"PHP","funding_links":[],"categories":["PHP","Packages"],"sub_categories":["Web Forms"],"readme":"# BootstrapForm, forms for Laravel 5\n\n![phpunit](https://github.com/dwightwatson/bootstrap-form/workflows/phpunit/badge.svg)\n[![Total Downloads](https://poser.pugx.org/watson/bootstrap-form/downloads.svg)](https://packagist.org/packages/watson/bootstrap-form)\n[![Latest Stable Version](https://poser.pugx.org/watson/bootstrap-form/v/stable.svg)](https://packagist.org/packages/watson/bootstrap-form)\n[![Latest Unstable Version](https://poser.pugx.org/watson/bootstrap-form/v/unstable.svg)](https://packagist.org/packages/watson/bootstrap-form)\n[![License](https://poser.pugx.org/watson/bootstrap-form/license.svg)](https://packagist.org/packages/watson/bootstrap-form)\n\nThis is a package for simply creating Bootstrap 3 styled form groups in Laravel 5. It extends the normal form builder to provide you with horizontal form groups completed with labels, error messages and appropriate class usage.\n\n## Introduction\n\nSimply use the `BootstrapForm` facade in the place of the `Form` facade when you want to generate a Bootstrap 3 form group.\n\n```php\nBootForm::text('username');\n```\n\nAnd you'll get back the following:\n\n```html\n\u003cdiv class=\"form-group\"\u003e\n    \u003clabel for=\"username\" class=\"control-label col-md-2\"\u003eUsername\u003c/label\u003e\n    \u003cdiv class=\"col-md-10\"\u003e\n        \u003cinput type=\"text\" name=\"username\" class=\"form-control\" /\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\nOf course, if there are errors for that field it will even populate them.\n\n```html\n\u003cdiv class=\"form-group has-error\"\u003e\n    \u003clabel for=\"username\" class=\"control-label col-md-2\"\u003eUsername\u003c/label\u003e\n    \u003cdiv class=\"col-md-10\"\u003e\n        \u003cinput type=\"text\" name=\"username\" class=\"form-control\" /\u003e\n        \u003cspan class=\"help-block\"\u003eThe username field is required.\u003c/span\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## Installation\n\nFirst, require the package using Composer.\n\n```shell\ncomposer require watson/bootstrap-form\n```\n\nNow, add these service providers to your `config/app.php` file (don't add the `HtmlServiceProvider` if you already have it).\n\n```php\nCollective\\Html\\HtmlServiceProvider::class,\nWatson\\BootstrapForm\\BootstrapFormServiceProvider::class,\n```\n\nAnd finally add these to the aliases array (note: Form and Html must be listed before BootstrapForm):\n\n```php\n'Form'     =\u003e Collective\\Html\\FormFacade::class,\n'HTML'     =\u003e Collective\\Html\\HtmlFacade::class,\n'BootForm' =\u003e Watson\\BootstrapForm\\Facades\\BootstrapForm::class,\n```\n\nFeel free to use a different alias for BootstrapForm if you'd prefer something shorter.\n\n## Configuration\n\nThere are a number of configuration options available for BootstrapForm. Run the following Artisan command to publish the configuration option to your `config` directory:\n\n```shell\nphp artisan vendor:publish\n```\n\n### Horizontal form sizes\n\nWhen using a horizontal form you can specify here the default sizes of the left and right columns. Note you can specify as many classes as you like for each column for improved mobile responsiveness, for example:\n\n```\ncol-md-3 col-sm-6 col-xs-12\n```\n\n### Display errors\n\nBy default this package will only display the first validation error for each field. If you'd instead like to list out all the validation errors for a field, simply set this configuration option to true.\n\n## Usage\n\n### Opening a form\n\nBootstrapForm has improved the process of opening forms, both in terms of providing Bootstrap classes as well as managing models for model-based forms.\n\n```php\n// Passing an existing, persisted model will trigger a model\n// binded form.\n$user = User::whereEmail('example@example.com')-\u003efirst();\n\n// Named routes\nBootForm::open(['model' =\u003e $user, 'store' =\u003e 'users.store', 'update' =\u003e 'users.update']);\n\n// Controller actions\nBootForm::open(['model' =\u003e $user, 'store' =\u003e 'UsersController@store', 'update' =\u003e 'UsersController@update']);\n```\n\nIf a model is passed to the open method, it will be configured to use the `update` route with the `PUT` method. Otherwise it will point to the `store` method as a `POST` request. This way you can use the same opening tag for a form that handles creating and saving.\n\n```php\n// Passing a model that hasn't been saved or a null value as the\n// model value will trigger a `store` form.\n$user = new User;\n\nBootForm::open()\n```\n\n#### Routing with parameters\n\nIf the route takes parametersyou can pass them by replacing the route or action name string bwith an array. The first entry is the string for route name, followed by the parameters as you'd pass them to the `route` function.\n\n```php\nBootForm::open(['update' =\u003e ['posts.comments.create', $post]])\n```\n\n### Form variations\n\nThere are a few helpers for opening the different kinds of Bootstrap forms. By default, `open()` will use the the form style that you have set in the configuration file. These helpers take the same input as the `open()` method.\n\n```php\n// Open a vertical Bootstrap form.\nBootForm::vertical();\n\n// Open an inline Bootstrap form.\nBootForm::inline();\n\n// Open a horizontal Bootstrap form.\nBootForm::horizontal();\n```\n\nIf you want to change the columns for a form for a deviation from the settings in your configuration file, you can also set them through the `$options` array.\n\n```php\nBootForm::open(['left_column_class' =\u003e 'col-md-2', 'left_column_offset_class' =\u003e 'col-md-offset-2', 'right_column_class' =\u003e 'col-md-10']);\n```\n\n### Text inputs\n\nHere are the various methods for text inputs. Note that the method signatures are relatively close to those provided by the Laravel form builder but take a parameter for the form label.\n\n```php\n// The label will be inferred as 'Username'.\nBootForm::text('username');\n\n// The field name by default is 'email'.\nBootForm::email();\n\nBootForm::textarea('profile');\n\n// The field name by default is 'password'.\nBootForm::password();\n```\n\n### Checkbox and radio button inputs\n\nCheckboxes and radio buttons are a little bit different and generate different markup.\n\nView the method signature for configuration options.\n\n```php\n// A checked checkbox.\nBootForm::checkbox('interests[]', 'Laravel', 'laravel', true);\n```\n\nSame goes for radio inputs.\n\n```php\nBootForm::radio('gender', 'Male', 'male');\n```\n\n#### Multiple checkboxes and radio buttons\n\nBy simply passing an array of value/label pairs you can generate a group of checkboxes or radio buttons easily.\n\n```php\n$label = 'this is just a label';\n\n$interests = [\n    'laravel' =\u003e 'Laravel',\n    'rails'   =\u003e 'Rails',\n    'ie6'     =\u003e 'Internet Explorer 6'\n];\n\n// Checkbox inputs with Laravel and Rails selected.\nBootForm::checkboxes('interests[]', $label, $interests, ['laravel', 'rails']);\n\n$genders = [\n    'male'   =\u003e 'Male',\n    'female' =\u003e 'Female'\n];\n\n// Gender inputs inline, 'Gender' label inferred.\nBootForm::radios('gender', null, $genders, null, true);\n\n// Gender inputs with female selected.\nBootForm::radios('gender', 'Gender', $genders, 'female');\n```\n\n### Submit button\n\n```php\n// Pretty simple.\nBootForm::submit('Login');\n```\n\n### Closing the form\n\n```php\n// Pretty simple.\nBootForm::close();\n```\n\n### Labels\n\n#### Hide Labels\n\nYou may hide an element's label by setting the the value to `false`.\n\n```php\n// An input with no label.\nBootForm::text('username', false);\n```\n\n#### Labels with HTML\n\nTo include HTML code inside a label:\n\n```php\n// A label with HTML code using array notation\nBootForm::text('username', ['html' =\u003e 'Username \u003cspan class=\"required\"\u003e*\u003c/span\u003e']);\n\n// A label with HTML code using HtmlString object\nBootForm::text('username', new Illuminate\\Support\\HtmlString('Username \u003cspan class=\"required\"\u003e*\u003c/span\u003e'));\n```\n\n### Help Text\n\nYou may pass a `help_text` option to any field to have [Bootstrap Help Text](https://getbootstrap.com/css/#forms-help-text) appended to the rendered form group.\n\n### Form input group (suffix and prefix)\n\nAdd prefix and/or suffix to any input - you can add text, icon and buttons.\n\n```php\n// Suffix button with 'Call' as label and success class to button\n{!! BootForm::text('tel', 'Phone', null, ['suffix' =\u003e BootForm::addonButton('Call', ['class' =\u003e 'btn-success'])] ) !!}\n\n// Prefix button with 'Call' as label and success class to button\n{!! BootForm::text('tel', 'Phone', null, ['prefix' =\u003e BootForm::addonButton('Call', ['class' =\u003e 'btn-success'])] ) !!}\n\n// Prefix icon (I put second parameter after \u003ci class=\"fa fa-SECOND_PARAMETER\"\u003e\u003c/i\u003e) with 'dollar' as icon\n{!! BootForm::text('tel', 'Phone', null, ['prefix' =\u003e BootForm::addonIcon('dollar')] ) !!}\n\n// Prefix and suffix as text\n{!! BootForm::text('tel', 'Phone', null, ['prefix' =\u003e BootForm::addonText('1-'), 'suffix' =\u003e BootForm::addonIcon('phone')] ) !!}\n\n// Prefix and suffix with button\n{!! BootForm::text('tel', 'Phone', null, ['suffix' =\u003e BootForm::addonButton('Boom!', ['class' =\u003e 'btn-danger']), 'prefix' =\u003e BootForm::addonButton('Call', ['class' =\u003e 'btn-success'])] ) !!}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwightwatson%2Fbootstrap-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwightwatson%2Fbootstrap-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwightwatson%2Fbootstrap-form/lists"}