In registration page, have dynamic steps for Wizard based of step's afterValidation

  • If @domain.com is domain of an existing tenant, add the user to that
  • Else send user to a "step 2" in the registration with 2 fields: Company / Team-name and Domain-name to set up a new Tenant.
    public function form(Form $form): Form
    {
        return $this->makeForm()
            ->schema([
                Wizard::make([
                    Wizard\Step::make('User Registration')
                        ->afterValidation(function () {
                            if ($someCondition) {
                              /* Get 2nd step and make hidden(false) */
                            }
                        })
                        ->description(__('Register as a Company Admin or as Regular User'))
                        ->schema([
                            $this->getNameFormComponent(),
                            $this->getLastNameFormComponent(),
                            $this->getEmailFormComponent(),
                            $this->getPasswordFormComponent(),
                            $this->getPasswordConfirmationFormComponent(),
                        ]),
                    Wizard\Step::make('Company Registration')
                        ->description(__('[Optional] For Company Admin'))
                        ->schema([
                            $this->getTenantFormComponent(),
                            $this->getDomainFormComponent(),
                        ]),
                ])->submitAction(new HtmlString(Blade::render(<<<BLADE
                    <x-filament::button
                        type="submit"
                        size="sm"
                    >
                        Submit
                    </x-filament::button>
                BLADE))),
            ])
            ->statePath('data');




I have tried skippable() but that only provides option to switch between steps.

Thanks in advance.
Screenshot_2024-05-06_at_8.49.36_AM.png
Solution
Personally, I would not make it a Wizard, but rather a set of hidden/visible fields based on the domain. Unless that Company Registration is a huge form.
Was this page helpful?