Created
October 27, 2015 21:59
-
-
Save stephanecoinon/c9b0feddd757090906d5 to your computer and use it in GitHub Desktop.
Macros for Laravel forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Macros for Laravel forms | |
| * | |
| * Laravel 4: Illuminate\Html\FormBuilder | |
| * Laravel 5: Collective\Html\FormFacade | |
| */ | |
| /* | |
| * Display validation error for a particular form field | |
| */ | |
| Form::macro('error', function ($fieldName, $errors) { | |
| if (! $errors->has($fieldName)) { | |
| return ''; | |
| } | |
| return $errors->first($fieldName, '<small class="error">:message</small>'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment