下拉我有两个实体学生和类,我想创建一个表单显示了学生的详细信息和类的下拉/ chocelist和一个类分配给学生。这些类也应该来自数据库表,所以控制器就是这样。symfony的3 UndefinedOptionsException - 从数据库
public function studentAddClassAction($id, Request $request)
{
// get the student from the student table
$em = $this->getDoctrine()->getManager();
$student= $em->getRepository('PIE10Bundle:Student')->find($id);
// new class object and create the form
$class = new Classes;
$form = $this->createForm(ClassesType::class, $class);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
// form operation - update student row with the classID
}
return $this->render(
'PIE10Bundle:student:layout_student_addclass.html.twig',
array(
'student'=> $student,
'title' => 'Add Class',
'tables' => 1,
'form' => $form->createView()
)
);
}
和我ClassesType就像下面
class ClassesType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('classes',
ClassesType::class,
array(
'class' => 'PIE10Bundle:Classes',
'property' => 'className',
'expanded' => false,
'multiple' => false
));
$builder->add('Add Class',
SubmitType::class,
array('attr' => array('class' => 'btn btn-primary',
'style' => 'margin:15px 0;')));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'PIE10Bundle\Entity\Classes',
));
}
}
,当我尝试访问此表单我正在以下500内部服务器错误 - UndefinedOptionsException错误
“类”,“扩展”,“多个”,“属性”选项不存在。定义的选项有:“action”,“allow_extra_fields”,“attr”,“auto_initialize”,“block_name”,“by_reference”,“compound”,“constraints”,“csrf_field_name”,“csrf_message”,“csrf_protection”,“csrf_token_id “,”csrf_token_manager“,”data“,”data_class“,”description“,”disabled“,”empty_data“,”error_bubbling“,”error_mapping“,”extra_fields_message“,”inherit_data“,”invalid_message“,”invalid_message_parameters“ label,label_attr,label_format,mapped,method,post_max_size_message,property_path,required,translation_domain,trim,validation_groups。
所以我需要知道哪里出了问题,以及如何解决这个问题。请让我知道是否需要其他信息。由于
谢谢你,我有三编辑它,它会给出'无法加载类型'PIE10Bundle \ Form \ EntityType'' – mapmalith
您需要*使用*正确的命名空间,我会更新我的答案。 – Yoshi
我已经添加了命名空间,但现在没有运气geting'选项“属性”不存在。定义的选项有:“action”,“allow_extra_fields”,“attr”,'....等 – mapmalith