craue / CraueFormFlowBundle

Multi-step forms for your Symfony project.
MIT License
736 stars 118 forks source link

fos user “db_driver” at path “fos_user” must be configured #321

Open andychan94 opened 6 years ago

andychan94 commented 6 years ago

Using symfony 3.4. Followed the Readme, but I am getting the following error:

Whoops, looks like something went wrong. (1/1) InvalidConfigurationException The child node "db_driver" at path "fos_user" must be configured.

Here is what I did,

// in app/AppKernel.php
public function registerBundles() {
    $bundles = array(
        // ...
        new Craue\FormFlowBundle\CraueFormFlowBundle(),
    );
    // ...
}

My CreateHouseFlow:

class CreateHouseFlow extends FormFlow
{
    protected function loadStepsConfig() {
        return array(
            array(
                'label' => 'wheels',
                'form_type' => AdminHouseFormType::class,
            ),
            array(
                'label' => 'engine',
                'form_type' => AdminHouseFormType::class,
                'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
                    return $estimatedCurrentStepNumber > 1 && !$flow->getFormData()->canHaveEngine();
                },
            ),
            array(
                'label' => 'confirmation',
            ),
        );
    }
}

my HouseFormType

class AdminHouseFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        switch ($options['flow_step']) {
            case 1:
                $builder
                    ->add('title', TextType::class, array(
                        'label' => 'Title',
                        'attr'=> array('class'=>'input')
                    ))
                    ....other fields
                    ;
                break;
            case 2:
                $builder
                    ->add('essentials', TextType::class, array(
                        'label' => 'Essentials',
                        'required' => false,
                        'attr'=> array('class'=>'input')
                    ))
                    ....other fields 
                    ;
                break;
        }
    }

    public function getBlockPrefix()
    {
        return 'createhouse';
    }
}

My createAction()

public function createAction(Request $request)
    {
        $house = new House();
        $flow = $this->get('app.form.flow.createhouse');                       
        $flow->bind($house); 
        $form = $flow->createForm();
        $form->handleRequest($request);
        if ($flow->isValid($form)) {
            $flow->saveCurrentStepData($form);
            if ($flow->nextStep()) {
                $form = $flow->createForm();
            } else {
                $em = $this->getDoctrine()->getManager();
                $em->persist($house);
                $em->flush();
                $flow->reset();
                $this->addFlash('success', 'Property added');
                return $this->redirect($this->generateUrl('proprent_index'));
            }
        }

        return $this->render(':dashboard/proprent:create.html.twig', [
            'form' => $form->createView(),
            'flow' => $flow,
        ]);
    }

services.yml:

app.form.flow.createhouse:
        class: AppBundle\Form\CreateHouseFlow
        parent: craue.form.flow

config.yml

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'

Why is the fosUserBundle error being shown? It has been working fine with these settings. If I remove parent: craue.form.flow from the form flow service, things load but the flow doesnt load. What am I doing wrong? Please help