Create Page: How to re-render component after mount and filled values from url params .

In the create create form I have values coming from the url and filled the inputs. I was able to populate the inputs but the problem is not being re render that is why the other fields that are meant to be visible are not showing even it meets the criteria to be visible.
8 Replies
LeandroFerreira
custom LW component or Filament resource?
Agcodex
Agcodex3d ago
Filament resource in the create page
LeandroFerreira
did you add this in the params? Are you using $this->your_param ?
use Livewire\Attributes\Url;

#[Url]
public $yourParam = '';
use Livewire\Attributes\Url;

#[Url]
public $yourParam = '';
Agcodex
Agcodex3d ago
No I am using the laravel request() to get the params value.
LeandroFerreira
try this
Agcodex
Agcodex3d ago
I filling it like this
#[Url]
public ?string $order_id = '';

#[Url]
public ?string $product_id = '';

#[Url]
public ?string $component_product = '';

protected function fillForm(): void
{
$this->callHook('beforeFill');

$order = Order::find($this->order_id);

$this->form->fill([
'order_id' => $order?->id,
'category' => $order?->category,
'product_id' => $this->product_id,
'component_product_id' => $this->component_product
]);

$this->callHook('afterFill');
}
#[Url]
public ?string $order_id = '';

#[Url]
public ?string $product_id = '';

#[Url]
public ?string $component_product = '';

protected function fillForm(): void
{
$this->callHook('beforeFill');

$order = Order::find($this->order_id);

$this->form->fill([
'order_id' => $order?->id,
'category' => $order?->category,
'product_id' => $this->product_id,
'component_product_id' => $this->component_product
]);

$this->callHook('afterFill');
}
It does the same thing, It populated the inputs but not re render.
LeandroFerreira
where are you re-render the component?
Agcodex
Agcodex3d ago
In my create form page, I have this field like if the category value is "X" show other fields, but when fill the input with value "X" the other fields are not showing. Do I need to dispatch an event in order to rerender the form? I just oeveriiding the fillForm method to populate the fields