├── LICENSE.md ├── README.md └── src └── laravel-bootstrap-modal-form.js /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jesse Leite 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel-Bootstrap-Modal-Form 2 | 3 | A form validation extension for your Laravel app. Use when embedding a [Bootstrap form](http://getbootstrap.com/css/#forms) into a [Bootstrap/jQuery modal](http://getbootstrap.com/javascript/#modals). This script keeps modal open, submits form via AJAX, queries your [Laravel validation](http://laravel.com/docs/validation) rules, and populates error messages. 4 | 5 |  6 | 7 | # Requirements 8 | 9 | - [Bootstrap CSS](http://getbootstrap.com/css/) 10 | - [Bootstrap JS](http://getbootstrap.com/javascript/) 11 | - [jQuery](http://jquery.com) 12 | 13 | # Quick Installation 14 | 15 | Via [Bower](http://bower.io): 16 | ``` 17 | bower install jerseymilker/laravel-bootstrap-modal-form --save 18 | ``` 19 | 20 | # Basic Usage 21 | 22 | - Embed [Bootstrap form](http://getbootstrap.com/css/#forms) into [Bootstrap/jQuery modal](http://getbootstrap.com/javascript/#modals). 23 | - Setup [Laravel validation](http://laravel.com/docs/validation). 24 | - Include this script. 25 | - Add `class="bootstrap-modal-form"` to form. 26 | - Add `class="bootstrap-modal-form-open"` to modal open button. 27 | 28 | # Additional Notes 29 | 30 | - Script does not handle CSRF tokens. Use Laravel's [_token field](http://laravel.com/docs/5.0/routing#csrf-protection) in your forms if needed. 31 | - Script submits via `POST` form action. Use Laravel's [method spoofing](http://laravel.com/docs/5.0/routing#method-spoofing) if you need to submit via `PUT`, `PATCH`, or `DELETE`. 32 | - If script detects file input, FormData object will be used (requires IE10+, more info on [browser compatibility here](https://developer.mozilla.org/en/docs/Web/API/FormData#Browser_compatibility)). 33 | 34 | # Shameless Plug 35 | 36 | I highly recommend [BootForms](http://github.com/adamwathan/bootforms) form builder package by [Adam Wathan](https://twitter.com/adamwathan). This is a great helper which makes generating Bootstrap form markup super easy. It even auto-detects Laravel's validation state and outputs error messages for most field types. 37 | 38 | Example: 39 | ```php 40 | {!! BootForm::text('First Name', 'first_name') !!} 41 | ``` 42 | Generates: 43 | ```php 44 |
:message
') !!} 48 |'+message+'
'); 99 | }); 100 | 101 | // Reset submit. 102 | if (submit.is('button')) { 103 | submit.html(submitOriginal); 104 | } else if (submit.is('input')) { 105 | submit.val(submitOriginal); 106 | } 107 | 108 | // If successful, reload. 109 | } else { 110 | location.reload(); 111 | } 112 | }); 113 | }); 114 | 115 | // Reset errors when opening modal. 116 | $('.bootstrap-modal-form-open').click(function() { 117 | resetModalFormErrors(); 118 | }); 119 | 120 | }); 121 | --------------------------------------------------------------------------------