0

i am trying to upgrade my application to symfony 3. But there a deprecation notice i can't fix:

My Code with Symfony 2 :

protected function configureFormFields(FormMapper $formMapper){
     ->add('town', 'sonata_type_model_autocomplete', array(
                'property'=>'name',
                'placeholder'=>'Select one',
                'label'=>'town.name,
     ));
}

The deprecation notice :

Accessing type "sonata_type_model_autocomplete" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "Sonata\AdminBundle\Form\Type\ModelAutocompleteType" instead

So, to be compliant with Symfony 3 :

use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;

protected function configureFormFields(FormMapper $formMapper){
             ->add('town', ModelAutocompleteType::class , array(
                        'property'=>'name',
                        'placeholder'=>'Select one',
                        'label'=>'town.name',
                        'model_manager'=> null
             ));
}

But i get this error :

Catchable Fatal Error: Argument 1 passed to Sonata\AdminBundle\Form\DataTransformer\ModelToIdPropertyTransformer::__construct() must implement interface Sonata\AdminBundle\Model\ModelManagerInterface, null given, called in /vendor/sonata-project/admin-bundle/Form/Type/ModelAutocompleteType.php on line 37 and defined

So instead of null, i have to pass an ModelManagerInterface object, but where i can find it ?

Thank you for reading

MatMouth
  • 858
  • 2
  • 7
  • 24

0 Answers0