diff --git a/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php b/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php index 4ae5b07..ce37c84 100644 --- a/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php +++ b/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php @@ -7,8 +7,8 @@ use Collective\Html\HtmlBuilder; use Illuminate\Support\ServiceProvider; use InvalidArgumentException; -use Kris\LaravelFormBuilder\Traits\ValidatesWhenResolved; use Kris\LaravelFormBuilder\Form; +use Kris\LaravelFormBuilder\Traits\ValidatesWhenResolved; class FormBuilderServiceProvider extends ServiceProvider { @@ -105,15 +105,15 @@ public function boot() __DIR__ . '/../../config/config.php' => config_path('laravel-form-builder.php') ]); - $form = $this->app[static::FORM_ABSTRACT]; - - $form->macro('customLabel', function($name, $value, $options = [], $escape_html = true) use ($form) { - if (isset($options['for']) && $for = $options['for']) { - unset($options['for']); - return $form->label($for, $value, $options, $escape_html); - } + $this->app->afterResolving(Form::class, function ($form) { + $form->macro('customLabel', function($name, $value, $options = [], $escape_html = true) use ($form) { + if (isset($options['for']) && $for = $options['for']) { + unset($options['for']); + return $form->label($for, $value, $options, $escape_html); + } - return $form->label($name, $value, $options, $escape_html); + return $form->label($name, $value, $options, $escape_html); + }); }); }