protonemedia / laravel-form-components

A set of Blade components to rapidly build forms with Tailwind CSS (v1.0 and v2.0) and Bootstrap 4/5. Supports validation, model binding, default values, translations, Laravel Livewire, includes default vendor styling and fully customizable!
https://protone.media/blog/laravel-form-components-to-rapidly-build-forms-with-tailwind-css-and-bootstrap-4
MIT License
815 stars 103 forks source link

Render does not return output #79

Closed RdeWilde closed 2 years ago

RdeWilde commented 2 years ago

Why does the render-method output a path instead of the view representation? According to the docs, it should return the content for the view: https://github.com/protonemedia/laravel-form-components/blob/9d387210801a5ed3f1f3f69a019b7549447d1cc6/src/Components/Component.php#L21 Base method doc:

Get the view / view contents that represent the component.

How can I render the output for the component from PHP?

I tried this, but as the render returns just a path, I don't get the actual output:

                $autocomplete = new FormAutocomplete(
                    'id',
                    'label'
                );
                echo $autocomplete->render();
pascalbaljet commented 2 years ago

You can return the path as well, the framework checks if it exists and then resolves it: https://github.com/laravel/framework/blob/v8.80.0/src/Illuminate/View/Component.php#L78 https://github.com/laravel/framework/blob/v8.80.0/src/Illuminate/View/Compilers/BladeCompiler.php#L300