AppVentus / AutoFormFillBundle

3 stars 1 forks source link

Exception #2

Open flopp26 opened 9 years ago

flopp26 commented 9 years ago

Hi, I have try your bundle and I get this exception on my form.

Unable to transform value for property path "birthday": Expected a \DateTime.

in my form type:

->add('birthday', 'date', array(
                'widget' => 'choice',
                'years'         => range(date('Y') - 10, date('Y') - 100),
                /** @Ignore */
                'empty_value'   => array('year' => 'year' , 'month' => 'month' , 'day' => 'day')
            ))
paulandrieux commented 9 years ago

Hi Florent,

The type "date" is not yet supported by AutoFormFillBundle. You can propose a PR with this improvement, I think you just have to add the following code in the Filler service (https://github.com/AppVentus/AutoFormFillBundle/blob/master/Service/Filler.php#L109) :

   case 'date':
   case 'datetime':
       $data = new \Date($this->faker->date);
       break;
paulandrieux commented 9 years ago

And just FYI, symfony2 provides a "birthday" field type which should match your need: http://symfony.com/doc/current/reference/forms/types/birthday.html