symfony 2.5 form validation error

99 views Asked by At

I have a form type A with some widgets and mapped to class C1. I need a new widget in this form which is not mapped to this class( i.e mapped to another class C2). So i have created a new form type B. This new form type B is included in form type A.

Form Type B:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('join_event', 'date', array(
            'label' => 'employee.form.join_event.label',
            'required' => true,
            'widget' => 'single_text',
             'attr' => array(
                'data-date-format' => 'MM-DD-YYYY'
            )

        ));
    }

FormType A including FormType B:

$builder->add('event', new FormTypeB(), array(
            'label' => false,
            'mapped' => false
));

The form display is well as expected but there is a validation error on submission with message "This value is not valid."

1

There are 1 answers

0
Rob On

I think the problem is related to the date-field itself.

See http://symfony.com/doc/current/reference/forms/types/date.html#format how to define the format.

Maybe sth like 'format' => 'MM-dd-yyyy' will work.