Skip to content

Instantly share code, notes, and snippets.

@stephanecoinon
Created October 27, 2015 21:59
Show Gist options
  • Select an option

  • Save stephanecoinon/c9b0feddd757090906d5 to your computer and use it in GitHub Desktop.

Select an option

Save stephanecoinon/c9b0feddd757090906d5 to your computer and use it in GitHub Desktop.
Macros for Laravel forms
/*
* 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