I never had this problem before, but I am trying to add a field to my registration form from FOSUserBundle. In results I have only the default form from the bundle and didn't get my birthday_date
field. What am I doing wrong?
RegistrationType class:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('birthday_date');
}
public function getParent()
{
return 'fos_user_registration';
}
public function getName()
{
return 'app_user_registration';
}
}
config.yml:
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\User
registration:
form:
name: app_user_registration
services.yml:
app.form.registration:
class: AppBundle\Form\RegistrationType
tags:
- { name: form.type, alias: app_user_registration }
I just follow the document instructions so i have no idea, where's the problem
Your getParent()
function should return the class of the parent form and not the name, these changes comes with versions > 2.8, check Overriding a Form Type
So your form type class should become:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('birthday_date');
}
public function getParent()
{
return 'FOS\UserBundle\Form\Type\RegistrationFormType';
}
public function getName()
{
return 'app_user_registration';
}
}