Form in custom page validation not working

class Checkout extends Page implements HasForms
{
use InteractsWithForms;
....

protected static string $view = 'filament.admin.resources.invoice-resource.pages.checkout';

public ?array $data = [];

public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
Forms\Components\Section::make('Payment Information')
->schema([
Forms\Components\Select::make('paymentMethod')
->label('Payment Method')
->options($this->getPaymentMethods())
->live()
->required(),

Forms\Components\Section::make(fn($get) => 'Payment with ' . $get('paymentMethod'))
->visible(fn($get) => $get('paymentMethod') !== null)
->schema(fn($get) => is_null($get('paymentMethod')) ? [] : $this->factory->resolve($get('paymentMethod'))->form()),
]),
]);
}
class Checkout extends Page implements HasForms
{
use InteractsWithForms;
....

protected static string $view = 'filament.admin.resources.invoice-resource.pages.checkout';

public ?array $data = [];

public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
Forms\Components\Section::make('Payment Information')
->schema([
Forms\Components\Select::make('paymentMethod')
->label('Payment Method')
->options($this->getPaymentMethods())
->live()
->required(),

Forms\Components\Section::make(fn($get) => 'Payment with ' . $get('paymentMethod'))
->visible(fn($get) => $get('paymentMethod') !== null)
->schema(fn($get) => is_null($get('paymentMethod')) ? [] : $this->factory->resolve($get('paymentMethod'))->form()),
]),
]);
}
the above code works but when submitting the form validation doesn't work even if the form is valid what im i doing wrong thanks
No description
1 Reply
omar abdou
omar abdouOP3w ago
array:3 [▼ // app/Filament/Admin/Resources/InvoiceResource/Pages/Checkout.php:133 "paymentMethod" => "Pesapal" "phoneNumber" => null "email" => null ] this the data from the submit action

Did you find this page helpful?