2012-09-10 18 views
6

私のSymfony 2.0.12プロジェクトを2.1にアップグレードするだけです。私はまた、FosUserBundleをインストールし、私はRegistrationFormType :: buildForm()互換性なし

php composer.phar update 

その後、作曲出力誤差をコマンドを実行すると:

Loading composer repositories with package information 
Updating dependencies 
Writing lock file 
Generating autoload files 
PHP Fatal error: Declaration of User\UserBundle\Form\Type\RegistrationFormType::buildForm() must be compatible with that of Symfony\Component\Form\FormTypeInterface::buildForm() in /home/mark/dev/proj/src/User/UserBundle/Form/Type/RegistrationFormType.php on line 38 

Fatal error: Declaration of User\UserBundle\Form\Type\RegistrationFormType::buildForm() must be compatible with that of Symfony\Component\Form\FormTypeInterface::buildForm() in /home/mark/dev/proj/src/User/UserBundle/Form/Type/RegistrationFormType.php on line 38 
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception 

それは私の前のRegistrationFormTypeは新しいsymfonyの2.1フォームインタフェースと互換性がありません何かを言います。

マイcomposer.json

// ... 
"friendsofsymfony/user-bundle": "*", 
//... 

マイRegistrationFormType.php

<?php 

namespace User\UserBundle\Form\Type; 

use Symfony\Component\Form\FormBuilderInterface; 
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType; 

class RegistrationFormType extends BaseType 
{ 
    public function buildForm(FormBuilder $builder, array $options) 
    { 
     parent::buildForm($builder, $options); 
     // add your custom field 
     $builder->add('name') 
       ->add('surname') 
       ->add('gender', 'choice', array(
        'choices' => array('m' => 'Male', 'f' => 'Female'), 
        'empty_value' => 'Please select', 
       )) 
       ->add('address') 
       ->add('zip') 
       ->add('country', 'country', array(
        'empty_value' => 'Please select', 
       )) 
      ->add('dateOfBirth', 'date', array(
       'empty_value' => '', 
       'years' => range(date('Y')-100, date('Y')), 
      )) 
      ->add('agree', 'checkbox', array(
       'label'  => 'Check here to agree to the sites terms and Conditions and Data Privacy Policy.', 
      )); 
    } 

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

任意のアイデアは、何が間違っているのですか?

答えて

17

あなたbuildFOrm方法は、古いスキーマを使用しています。これは、変更されました:

public function buildForm(FormBuilderInterface $builder, array $options) 

また、あなたが新しいものを含んで確実...

use Symfony\Component\Form\FormBuilderInterface; 
+0

感謝。できます。 – repincln