Skip to content

Commit 268c947

Browse files
Fix bug
1 parent 3831a1b commit 268c947

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

helpers/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function getFormBuilderViewPath(string $fileName): string
1414

1515
$path = base_path('resources/views/vendor/laravel-form-builder/' . $fileName);
1616

17-
return file_exists($path) ? $path : __DIR__ . '/views/' . $fileName;
17+
return file_exists($path) ? $path : __DIR__ . '/../resources/views/' . $fileName;
1818
}
1919
}
2020

src/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected function isPlain(): bool
207207
return static::class === $this->formBuilder->getFormClass();
208208
}
209209

210-
public function buildForm()
210+
public function buildForm(): void
211211
{
212212
}
213213

src/FormBuilderServiceProvider.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public function register(): void
4949
$this->app->alias('form', LaravelForm::class);
5050

5151
$this->registerBladeDirectives();
52-
$this->registerFormHelper();
53-
$this->registerFormBuilder();
5452
}
5553

5654
protected function registerBladeDirectives(): void
@@ -229,14 +227,17 @@ public function boot(): void
229227
__DIR__ . '/../config/config.php' => config_path('laravel-form-builder.php'),
230228
]);
231229

232-
$form = $this->app[static::FORM_ABSTRACT];
230+
$this->registerFormHelper();
231+
$this->registerFormBuilder();
233232

234-
$form->macro('customLabel', function ($name, $value, $options = [], $escapeHtml = true) use ($form) {
235-
if (isset($options['for']) && $for = $options['for']) {
236-
unset($options['for']);
233+
$this->app->afterResolving('form', function (LaravelForm $form) {
234+
$form->macro('customLabel', function ($name, $value, $options = [], $escapeHtml = true) use ($form) {
235+
if (isset($options['for']) && $for = $options['for']) {
236+
unset($options['for']);
237237

238-
return $form->label($for, $value, $options, $escapeHtml);
239-
}
238+
return $form->label($for, $value, $options, $escapeHtml);
239+
}
240+
});
240241
});
241242
}
242243

0 commit comments

Comments
 (0)