symfony 3.4: формы: использовать преобразователи данных - PullRequest
0 голосов
/ 29 мая 2020

пытается использовать преобразователь данных, у меня возникает ошибка при загрузке моей html формы

В моем классе formType

   use Doctrine\ORM\EntityManagerInterface;

class PmpType extends AbstractType
{
    private $entityManager;

    public function __construct(EntityManagerInterface $entityManager)
    {
        $this->entityManager = $entityManager;
    }

в моем приложении \ config \ services.yml

services:
# default configuration for services in *this* file
 _defaults:
    # automatically injects dependencies in your services
    autowire: true
    # automatically registers your services as commands, event subscribers, etc.
    autoconfigure: true
    # this means you cannot fetch services directly from the container via $container->get()
    # if you need to do this, you can override this setting on individual services
    public: true

но я получил эту ошибку

Type error: Too few arguments to function myApp\Bundle\Form\PmpType::__construct(), 0 passed in \vendor\symfony\symfony\src\Symfony\Component\Form\FormRegistry.php on line 92 and exactly 1 expected

Что мне не хватает

Thx for hepl

1 Ответ

0 голосов
/ 29 мая 2020

Хорошо, я не понимаю, почему, но я должен установить сервис для своего класса: в service.yml я добавляю

    seims_pmp.pmptype:
      class: SEISM\PmpIG56Bundle\Form\PmpType
      arguments: ["@doctrine.orm.entity_manager"]
      tags: [form.type]

, и теперь он работает

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...