我想生成一个表格来添加药剂,但他不认识这个方法
控制器
$public function addAction (Request $Request)
{
$Medicament = new Medicament();
$form = $this->
createForm(ModeleType::class,$Medicament);
$form->handleRequest($Request);
if ($form->isValid())
{
$em=$this->getDoctrine()->getManager();
$em->persist($Medicament);
$em->flush();
return $this->redirect($this->generateUrl(
'Pharmacie_Medicament_Add'
));
}
表格
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('nom')->add('quantite')->add('datePeremption')->add('prix')
->add('save',SubmitType::class);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'PharmacieCentraleBundle\Entity\Medicament'
));
}
public function getBlockPrefix()
{
return 'pharmaciecentralebundle_medicament';
}
尝试调用名为" createForm"的未定义方法。班级
PharmacieCentraleBundle\Controller\MedicamentController
忽略这一点:kjetrzejkbfckzejvbkejvbkarebvnreblheabv eafvkljbeamjkvbelvbvbelvblb ealvberavhrve
答案 0 :(得分:1)
在createForm
函数参数中,您需要传递MedicamentType
的实例,而不是Medicament