<?php
namespace App\Form\Registration;
use Craue\FormFlowBundle\Form\FormFlow;
use Symfony\Component\Form\FormInterface;
use Craue\FormFlowBundle\Form\FormFlowInterface;
class RegistrationFormFlow extends FormFlow
{
protected $allowDynamicStepNavigation = true;
protected function loadStepsConfig(): array
{
return [
[
'label' => 'Personal Info',
'form_type' => RegistrationBaseFormType::class,
'form_options' => [
'validation_groups' => function (FormInterface $form) {
$data = $form->getData();
if ($data->getCountry() == 'CA') {
return ['Default', 'CA'];
}
return ['Default', 'US'];
},
],
],
[
'label' => 'Brand Info',
'form_type' => BrandInfoFormType::class,
'form_options' => [
'validation_groups' => ['Default'],
],
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
$user = $flow->getFormData();
return $user->getId() !== null;
},
],
[
'label' => 'Retailer Info',
'form_type' => AddRetailerFormType::class,
'form_options' => [
'validation_groups' => ['Default'],
],
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
$user = $flow->getFormData();
// Skip if user already has retailers (added after merging)
if ($user->getUserRetailers()->count() > 0) {
return true;
}
return false;
// Skip for MK or Revelation brands
# return $estimatedCurrentStepNumber > 2 && ($flow->getFormData()->brand && ($flow->getFormData()->brand->isMk() || $flow->getFormData()->brand->isRevelation()));
# return !$user->getStoreId() && !$user->brand;
},
],
/*[
'label' => 'Invitation Code',
'form_type' => AddInvitationCodeFormType::class,
'form_options' => [
'validation_groups' => ['Default'],
],
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
$user = $flow->getFormData();
return !$user->brand OR (!$flow->getFormData()->brand->isMk() AND !$flow->getFormData()->brand->isRevelation());
return $user->getId() !== null || ($user->brand AND !$user->brand->isMk() AND !$user->brand->isRevelation());
},
],*/
[
'label' => 'Supplier Info',
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
$user = $flow->getFormData();
return $user->getId() !== null;
},
],
[
'label' => 'Jewelry Rewards Program',
'form_type' => OptInFormType::class,
'form_options' => [
'validation_groups' => function($form){
if($form->getData()->isOptOut()){
return ['Default'];
}
return ['Default', 'OPT_IN'];
},
],
'skip' => true
],
[
'label' => 'Tax Info (US)',
'form_type' => W9FormType::class,
'form_options' => [
'validation_groups' => function($form){
if($form->getData()->isOptOut()){
return ['Default'];
}
return ['Default', 'OPT_IN'];
},
],
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $flow->getFormData()->isOptOut() || $flow->getFormData()->getCountry() === 'CA';
},
],
[
'label' => 'Tax Info (Canada)',
'form_type' => W8FormType::class,
'form_options' => [
'validation_groups' => function($form){
if($form->getData()->isOptOut()){
return ['Default'];
}
return ['Default', 'OPT_IN'];
},
],
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $flow->getFormData()->isOptOut() || $flow->getFormData()->getCountry() !== 'CA';
},
],
[
'label' => 'Terms & Conditions',
'form_type' => RegistrationTermsFormType::class,
'form_options' => [
'validation_groups' => ['Default'],
],
],
[
'label' => 'Review and Register Below',
],
];
}
}