Share form problem.
My Form class
From my VendorDetail page which is infolist
While try to save form
It works when I comment product_id select field but in my case this field is hidden.
final class ProductForm
{
/**
*
* @return array<int, mixed>
*/
public static function getFields(mixed $productId = null): array
{
return [
Select::make('product_id')
->hidden(function () use ($productId) {
return $productId !== null;
})
->relationship('product', 'name')
->required(),
TextInput::make('price')
->required()
->maxLength(55)
];
}
}final class ProductForm
{
/**
*
* @return array<int, mixed>
*/
public static function getFields(mixed $productId = null): array
{
return [
Select::make('product_id')
->hidden(function () use ($productId) {
return $productId !== null;
})
->relationship('product', 'name')
->required(),
TextInput::make('price')
->required()
->maxLength(55)
];
}
}From my VendorDetail page which is infolist
public function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
Section::make('Products')
->collapsible()
->collapsed()
->headerActions([
Actions\Action::make('create_product')
->icon('heroicon-s-user-plus')
->form(ProductForm::getFields($this->record?->id))
->action(function ($data) {
dd($data);
}),
])
]);
} public function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
Section::make('Products')
->collapsible()
->collapsed()
->headerActions([
Actions\Action::make('create_product')
->icon('heroicon-s-user-plus')
->form(ProductForm::getFields($this->record?->id))
->action(function ($data) {
dd($data);
}),
])
]);
}While try to save form
It works when I comment product_id select field but in my case this field is hidden.
