我正在尝试使用liform或liform-bundle在我的控制器中生成我的表单类型的JSON,但收到错误:
CRITICAL - 未捕获的PHP异常Symfony \ Component \ Debug \ Exception \ UndefinedMethodException:“尝试调用类”Symfony \ Component \ Form \ Extension \ DataCollector \ Proxy \ ResolvedTypeDataCollectorProxy“的名为”getBlockPrefix“的未定义方法。” at /home/admin/Documents/displayce/code/vendor/limenius/liform/src/Limenius/Liform/FormUtil.php第39行
我控制器中的代码:
$form = $this->createForm(new FormType(), $entity, array(
'method' => 'PUT',
'csrf_protection' => false,
));
$schema = json_encode($this->get('liform')->transform($form));
我的表单类型代码:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('startDate', 'date', array(
'label' => 'Start Date',
'required' => false,
'widget' => 'single_text',
'format' => 'dd/MM/yyyy',
'input' => 'datetime',
))
->add('endDate', 'date', array(
'label' => 'End Date (included)',
'required' => false,
'widget' => 'single_text',
'format' => 'dd/MM/yyyy',
'input' => 'datetime',
))
->add('name', 'text', array(
'label' => 'Name',
'max_length' => 255,
))
->add('budget', 'money', array(
'label' => 'Budget (target)',
'required' => true,
'scale' => 0, // not showing decimals
))
->add('target', 'targeting', array(
'cascade_validation' => true,
));
}
和定位类型:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('contexts', 'entity', array(
'label' => 'Context(s)',
'class' => 'AppBundle\Entity\Context',
'choice_label' => 'name',
'expanded' => false,
'multiple' => true,
'required' => false,
))
->add('contextDetails', 'entity', array(
'label' => 'Detailed Context(s)',
'class' => 'AppBundle\Entity\ContextDetail',
'choice_label' => 'name',
'group_by' => 'context.name',
'expanded' => false,
'multiple' => true,
'required' => false,
))
->add('dataVariables', 'entity', array(
'label' => 'Variable',
'class' => 'AppBundle\Entity\DataVariable',
'choice_label' => 'name',
'expanded' => false,
'multiple' => true,
'group_by' => function($dataVariable, $key, $index) {
return $dataVariable->getDataProvider()->getName();
}
))
// Include criteria
->add('region', 'choice', array(
'label' => 'Region(s)',
'choices' => RegionDepartment::$regions,
'expanded' => false,
'multiple' => true,
'required' => false,
))
->add('department', 'choice', array(
'label' => 'Department(s)',
'choices' => RegionDepartment::$departments,
'expanded' => false,
'multiple' => true,
'required' => false,
))
;
可能是因为我使用嵌套的formtype?
我的目标是将symfony FormType与React Component结合起来,只要您可以将我重定向到解决方案来做到这一点,我会很高兴。
答案 0 :(得分:0)
将getBlockPrefix添加到您的formType和定位类型,如下所示:
val mDF: DataFrame = spark.read.option("header", "true").option("inferSchema", "true").csv("src/test/resources/knimeMergedTRimmedVariables.csv")
val mDFTyped = castAllTypedColumnsTo(mDF, IntegerType, DoubleType)
val indexer = new StringIndexer()
.setInputCol("Majors_Final")
.setOutputCol("Majors_Final_Indexed")
val mDFTypedIndexed = indexer.fit(mDFTyped).transform(mDFTyped)
val mDFFinal = castColumnTo(mDFTypedIndexed,"Majors_Final_Indexed", IntegerType)
mDFFinal.show()
//only doubles accepted by sparse vector, so that's what we filter for
val fieldSeq: scala.collection.Seq[StructField] = mDFFinal.schema.fields.toSeq.filter(f => f.dataType == DoubleType)
val fieldNameSeq: Seq[String] = fieldSeq.map(f => f.name)
var positionsArray: ArrayBuffer[LabeledPoint] = ArrayBuffer[LabeledPoint]()
mDFFinal.collect().foreach
{
row => positionsArray+=convertRowToLabeledPoint(row,fieldNameSeq,row.getAs("Majors_Final_Indexed"));
}
val mRdd:RDD[LabeledPoint]= spark.sparkContext.parallelize(positionsArray.toSeq)
MLUtils.saveAsLibSVMFile(mRdd, "./output/libsvm")
答案 1 :(得分:0)
我将bundle更改为 - > getBlockPrefix为 - > getName(),因为第一个不在Symfony 2.7中的Form.php中