我的代码存在一些问题,它有单独的表单,控制器和服务。这里的问题在哪里?
表单:https://pastebin.com/ERU6hChv 控制器:https://pastebin.com/FMzJ493v 服务:
# app/config/services.yml
services:
app.form.type.przydzial:
class: AppBundle\Form\PrzydzialType
arguments: ['@session']
tags:
- { name: form.type }
不幸的是我有一个警告:
"Warning: Missing argument 1 for AppBundle\Form\PrzydzialType::__construct(), called in G:\Xampp\htdocs\projects\godziny_inz\vendor\symfony\symfony\src\Symfony\Component\Form\FormRegistry.php on line 85 and defined"
堆栈追踪:
"in src\AppBundle\Form\PrzydzialType.php at line 64"
return 'appbundle_przydzial';
}
public function __construct($session)
{
$this->session = $session; <----------64 line
编辑:
if i change this line:
$form = $this->createForm('AppBundle\Form\PrzydzialType', $przydzial);
to
$form = $this->createForm('app.form.type.przydzial', $przydzial);
我有不同的警告:
无法加载“app.form.type.przydzial”
类型堆栈追踪:
在第87行的vendor \ symfony \ symfony \ src \ Symfony \ Component \ Form \ FormRegistry.php中
if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) {
$type = new $name();
} else {
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name)); <---line 87
}
}