aerni / statamic-livewire-forms

Supercharge your Statamic forms with Livewire
https://statamic.com/addons/aerni/livewire-forms
Other
28 stars 2 forks source link

How to pass parameter to form view #42

Closed sefaYavuz closed 1 year ago

sefaYavuz commented 1 year ago

I want to pass a parameter to the form view like this using blade:

<livewire:form handle="order" :extract="$extract" />

I've added the property to the Component like this:

class OrderForm extends BaseForm
{
    /*
    |--------------------------------------------------------------------------
    | Initialize Properties
    |--------------------------------------------------------------------------
    |
    | You may override the form's view and theme.
    |
    */

    protected static $VIEW = 'order';
    protected static $THEME = 'order';

    public $extract;

    // other code...
}

But I get null when I do this. How do I pass the parameter and receive the correct value of $extract

aerni commented 1 year ago

You'll have to call your own custom component in the view:

<livewire:order-form handle="order" :extract="$extract" />

You may also define the form handle in the view with protected static $HANDLE = 'order'. Then you can simply use the component like this:

<livewire:order-form :extract="$extract" />