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
LeandroFerreira5mo ago
custom LW component or Filament resource?
Gerald Afable
Gerald AfableOP5mo ago
Filament resource in the create page
LeandroFerreira
LeandroFerreira5mo ago
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 = '';
Gerald Afable
Gerald AfableOP5mo ago
No I am using the laravel request() to get the params value.
LeandroFerreira
LeandroFerreira5mo ago
try this
Gerald Afable
Gerald AfableOP5mo 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
LeandroFerreira5mo ago
where are you re-render the component?
Gerald Afable
Gerald AfableOP5mo 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
Want results from more Discord servers?
Add your server