craue / CraueFormFlowBundle

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

Bug - Fields not mapped are lost accross steps #400

Open fdiedler opened 2 years ago

fdiedler commented 2 years ago

Hi,

After investigating, all fields in the current step that are not mapped (attribut mapped => false) are lost if I click on "previous" button.

Example with only 2 steps (the not mapped field is located at step 1) :

class PropertyContractType extends AbstractType
{
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'label' => false,
            'data_class' => PropertyContract::class,
        ]);
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if ($options["flow_step"] == 1)
        {
            // Step 1
            $builder
                ->add('step1Field', ChoiceType::class, [
                    'choices' => ['....'],
                ])
                ->add('invoiceMin', TextType::class, [
                    'label' => 'Field not mapped',
                    'mapped' => false,
                ])
            ;
        }
        else
        {
            // Step 2
            $builder
                ->add('step2Field', TextType::class)
            ;
        }
    }
}

The invoiceMin data is available at step 2 (in the request object because not mapped to the entity) but if I press "previous" button, the invoiceMin data is lost.

Is it a bug or something that I don't understand ?

NB : This issue refers to this one https://github.com/craue/CraueFormFlowBundle/issues/399

Thanks,