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');
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.
No description
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.
Jump to solution
5 Replies
Solution
Povilas K
Povilas K3mo ago
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.
Jigar D
Jigar D2mo ago
From the email, I have to fetch the domain if the company exists with us. Thanks Povilas, I will try this approach of show/hide tonight.
Jigar D
Jigar D2mo ago
Thanks @PovilasKorop , I have sent this for review. Let's hope it get's clear. I will mark this as solved. Thanks again.
Jigar D
Jigar D2mo ago
I have also highlighted the security risk that people/hackers will figure out all the domains that are with us.
Povilas K
Povilas K2mo ago
@Jigar D very elegantly solved, congrats! With security risk, yes it's implied with the logic that you chose for this. Another approach would be to send invites personally for registration from that specific company domain. And more approaches exist, I'm sure.