Closed Zheka2011 closed 4 years ago
Regarding <livewire:forms.create-order :orders="$orders" />
Your error looks like it's coming from the view orders.blade.php
and not the form generator. Do you have any model tied to that variable?
Try to changing this:
public function mount( ? Orders $orders)
to
public function mount(?Orders $orders)
$orders
is just ONE item, not multiple. (sounds like plural to me)Changed the name of the variable to $order
, writes the same, Undefined variable: order
Can you please temporarily remove the form tag and just echo out the $order to make sure it is nothing wrong with your variable.
{{$order}}
-> Undefined variable: order
I'm trying to figure out why I can't see the variable.
It seems to me that the variable is not passed from here
public function mount(?Orders $order) {
//Gate::authorize()
$this->fill([
'formTitle' => trans('global.create') . ' ' . trans('crud.orders.title_singular'),
'wrapWithView' => false, //see https://github.com/tanthammar/tall-forms/wiki/installation/Wrapper-Layout
'showGoBack' => false,
]);
$this->mount_form($order); // $orders from hereon, called $this->model
}
If I understand you correctly you still get the error when you remove the form from your view?
Or are you trying to use a route that returns the Livewire full page component directly?
i got same problem... i hope you can give us some demo to use the element of this package... edited : i got my form work after declare public variable and add it to my main controller
@Zheka2011 and @santhika29
The problem you are experiencing is not due to this package. It is due to that you are trying to pass an undefined variable to the component.
It is standard php, that you cannot use an undefined variable.
In basic Laravel you create a route, you create a controller where you define a variable and you create a view, where you can echo that variable. You can also create routes with optional model binding.
With default Livewire you create components. You can pass variables to those components. But the variable must exist.
The value of the variable can be null
.
Please read Laravel documentation on how to pass variable to Blade components.
Then read Livewire documentation on how to pass variables to Livewire inline
components AND how to use Livewire routes with full-page
components
This package is just a Trait for a Livewire component. It behaves like a standard Livewire component.
inline
component)full-page
component)Livewire documentation on how to render inline
and full-page
components:
https://laravel-livewire.com/docs/2.x/rendering-components
You have not told me if you are trying to render a full-page component or if you are applying the component in a view. It is impossible for me to help you further before you understand the Livewire basics.
But I can assure you that the problem you are describing does not exist in this package.
Closing due to lack of response.
Hello. I am new to laravel. I want to use your package for my project. But something does not work out, I have already read the entire wiki. Created a form
php artisan make:tall-form createOrder --model=Orders --path=Forms --action=create
/app/Http/Livewire/Forms/createOrder.php
resources/views/livewire/orders.blade.php
<livewire:forms.create-order :orders="$orders" />
I get an error
Laravel 8 Livewire 2.3.1