Download the PHP package goldcarrot/laravel-bootstrap-forms without Composer
On this page you can find all versions of the php package goldcarrot/laravel-bootstrap-forms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download goldcarrot/laravel-bootstrap-forms
More information about goldcarrot/laravel-bootstrap-forms
Files in goldcarrot/laravel-bootstrap-forms
Package laravel-bootstrap-forms
Short Description Provides an easy way to use bootstrap components within your Laravel projects.
License MIT
Informations about the package laravel-bootstrap-forms
Laravel Bootstrap Forms.
- Installation
- Opening A Form
- Text, Text Area, Date, Number & Password Fields
- Checkboxes and Radio Buttons
- Drop-Down Lists
- Generating A Submit Button
- Supported Methods
- Using Resource With Localed Fields
- Example Register Form
- Add Custom Style To The Component
- Using Multilingual Form Tabs
- Manage Locales
- Using Bootstrap 3
- Add Custom Component
Installation
Begin by installing this package through Composer. Edit your project's
composer.json
file to requirelaraeast/laravel-bootstrap-forms
.You should publish the flags icons in public path to display in multilingual form tabs.
Opening A Form
By default, a
POST
method will be assumed; however, you are free to specify another method:Note: Since HTML forms only support
POST
andGET
,PUT
andDELETE
methods will be spoofed by automatically adding a_method
hidden field to your form.You may also open forms with method as well:
You may also open forms that point to named routes or controller actions:
You may pass in route parameters as well:
Text, Text Area, Date, Number & Password Fields
Generating A Text Input
Specifying A Default Value
Note: The date, number and textarea methods have the same signature as the text method.
Generating A Password Input
Generating Other Inputs
Checkboxes and Radio Buttons
Generating A Checkbox Or Radio Input
By default, will send default value "0" with an unchecked checkbox, if you want to disable it globally set the configuration key "laravel-bootstrap-forms.checkboxes.hasDefaultValue": true
Drop-Down Lists
Generating A Drop-Down List With Selected Default
Generating a Drop-Down List With an Empty Placeholder
Generating A Grouped List
Generating A Submit Button
Generateing A Submit Button With Bootstrap Button Style
Supported Methods
->label($label)
: To Generate label to the specified field.
->name($name)
: To Generate label to the specified field.
->placeholder($placeholder)
: To Set placeholder attribute to the specified field.
->min($min)
: To Set min attribute to the specified number field.
->max($max)
: To Set max attribute to the specified number field.
->step($step)
: To Set step attribute to the specified number field.
->multiple($bool = true)
: To Set multiple attribute to the specified select and file fields.
->note($note)
: To Sethelp-block
to the specified field.
->name($name)
: To Set the name of to the specified field.
->value($value)
: To Set the value of to the specified field as default will setold('name')
.
->inlineValidation($bool = true)
: To display validation errors in the specified field.
->style($style = 'default')
: To Set style to the specified field. supported['default', 'vertical']
.
->close()
: To close the form tag.
Using Resource With Localed Fields
You may add localed labels, notes and placeholders using resource option as well:
You must add
users.php
file to theresources/lang/en/
path and set the default attributes and notes, placeholders as well:
Using Custom Error Message Bag
You can using custom error bag to display validation errors without any conflict.
Example Register Form
Using Multilingual Form Tabs
Note : the input name inside
@bsMultilangualFormTabs
and@endBsMultilangualFormTabs
suffix with:{lang}
.Ex. if your supported language is
ar
&en
the input will named withname:ar
&name:en
.You should use Astrotomic/laravel-translatable and configure it's rule_factory with key format
\Astrotomic\Translatable\Validation\RuleFactory::FORMAT_KEY
to fill the multilingual data like the following example.
Manage Locales
You can add your supported locales in
locales.php
config file. you will get it using the following command:
Using Bootstrap 3
If you want to use bootstrap 3 you should publish the config file using the following commad and set the bootstrap version globally.
After change bootstrap version you should clear the cached view files using the
view:clear
artisan command.
Add Custom Style To The Component
run the
vendor:publish
artusan command to override components views as well.will override components in
resources/views/vendor/BsForm
path.you can copy
default.blade.php
file ascustom.blade.php
and use custom style as well :you can also set the style globally with
BsForm::style()
method before the form open as well :or
To reset the custom style to the default you should call
clearStyle()
method as well:For Example :
Add Custom Component
You may add new component class extends
BaseComponent
and regoster it in yourboot()
method inAppServiceProvider
class as well:Then register the component class in
boot()
method in yourAppServiceProvider
class as well :Then publish the BsForm views and create the new component file in
views/vendor/BsForm/bootstrap4/components/image/default.blade.php
path.Eexample content of
views/vendor/BsForm/bootstrap4/components/image/default.blade.php
file :