0

How to override the SonataUserBundle form edit profile ?

Here the code

config.yml
# fos User
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Application\Sonata\UserBundle\Entity\User
    profile:
        form:
            type: sonata_user_profile
    group:
        group_class: Application\Sonata\UserBundle\Entity\Group

services:
   sonata_user_profile.profile.form.type:
      class: Application\Sonata\UserBundle\Form\Type\ProfileType
      tags:
        - { name: form.type, alias: sonata_user_profile }
      arguments: [%fos_user.model.user.class%]

ProfilType.php

<?php

namespace Application\Sonata\UserBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ProfileType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('gender', null, array('required' => true))
            ->add('firstname', null, array('required' => true))
            ->add('lastname', null, array('required' => true))
            ->add('dateOfBirth', 'birthday', array('required' => true))
            ->add('label', null, array('required' => true))
        ;
    }

    public function getName()
    {
        return 'sonata_user_profile';
    }
}

i don't understand, the form is not override, and the service seem not to be loaded.

if i put an error in the ProfileType.php in my /src/Application/Sonata/UserBundle/Form/Type/

it change nothing, no error on the front...

ibasaw
  • 493
  • 1
  • 7
  • 22

1 Answers1

0

resolved!

i must to add the route in my bundle, then override the controller and use the new service

ibasaw
  • 493
  • 1
  • 7
  • 22
  • 1
    which route you have to add? And please tell how to override the controller – Marcel Djaman Jun 07 '14 at 12:58
  • the routes to add to your routing.yml are explain here: http://sonata-project.org/bundles/user/2-2/doc/reference/installation.html and to ovveride a bundle here: http://symfony.com/doc/current/cookbook/bundles/override.html – ibasaw Jun 10 '14 at 07:19