自升级到 TYPO3 6.2 extbase 后,多个 Select 不工作
Multiple Select not working since upgrade to TYPO3 6.2 extbase
我刚刚检查过,在我使用 TYPO3 4.7
的工作版本中,html 输出似乎与此相同
我有一个约会可以有多个学生。我通过自动完成文本输入字段将它们添加到 multi-select。
<input type="text" id="student-autocomplete"/>
<br/>
<f:form.select id="selected-students"
multiple="true"
property="students"
options="{appointment.students}"
optionLabelField="fullName"
class="" />
这是输出 - 在这个例子中我添加了两个学生。
输入隐藏字段似乎是由 fluid(?) 自动生成的:
<input type="hidden" value="" name="tx_extname_appoints[appointment][students]">
<select id="selected-students" name="tx_extname_appoints[appointment][students][]" multiple="true">
<option value="160">student1</option>
<option value="52">student 2</option>
</select>
现在我真正不明白的是:
当我的 select 中只有一个学生时它有效,但是当我有多个学生时我得到以下错误:
Caught exception: Exception while property mapping at property path "students":It is not allowed to map property "1". You need to use $propertyMappingConfiguration->allowProperties('1') to enable mapping of this property.
我假设“1”指的是我的第二个数组索引?但我不知道出了什么问题,因为它在 TYPO3 4.7 中似乎工作正常。
我应该用 new 属性 映射器做些什么吗?
我应该尝试更改模型中的某些内容吗?:
/**
* students
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\ExtName\Domain\Model\Student>
*/
protected $students = NULL;
/**
* Sets the students
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\ExtName\Domain\Model\Student> $students
* @return void
*/
public function setStudents(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $students) {
$this->students = $students;
}
我说不出原因,为什么你会看到这个异常,但你可以尝试让 PropertyMapper 对这个集合放宽一点。
为此,您需要在同一控制器中使用 initialize[yourAction]()
方法。
在那里你应该放这样的东西:
$this->arguments['appointment']
->getPropertyMappingConfiguration()
->forProperty('students.*')
->allowAllProperties();
这将告诉 PropertyMapper 对 'students' 集合 属性 不严格。
我刚刚检查过,在我使用 TYPO3 4.7
的工作版本中,html 输出似乎与此相同
我有一个约会可以有多个学生。我通过自动完成文本输入字段将它们添加到 multi-select。
<input type="text" id="student-autocomplete"/>
<br/>
<f:form.select id="selected-students"
multiple="true"
property="students"
options="{appointment.students}"
optionLabelField="fullName"
class="" />
这是输出 - 在这个例子中我添加了两个学生。
输入隐藏字段似乎是由 fluid(?) 自动生成的:
<input type="hidden" value="" name="tx_extname_appoints[appointment][students]">
<select id="selected-students" name="tx_extname_appoints[appointment][students][]" multiple="true">
<option value="160">student1</option>
<option value="52">student 2</option>
</select>
现在我真正不明白的是: 当我的 select 中只有一个学生时它有效,但是当我有多个学生时我得到以下错误:
Caught exception: Exception while property mapping at property path "students":It is not allowed to map property "1". You need to use $propertyMappingConfiguration->allowProperties('1') to enable mapping of this property.
我假设“1”指的是我的第二个数组索引?但我不知道出了什么问题,因为它在 TYPO3 4.7 中似乎工作正常。
我应该用 new 属性 映射器做些什么吗?
我应该尝试更改模型中的某些内容吗?:
/**
* students
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\ExtName\Domain\Model\Student>
*/
protected $students = NULL;
/**
* Sets the students
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\ExtName\Domain\Model\Student> $students
* @return void
*/
public function setStudents(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $students) {
$this->students = $students;
}
我说不出原因,为什么你会看到这个异常,但你可以尝试让 PropertyMapper 对这个集合放宽一点。
为此,您需要在同一控制器中使用 initialize[yourAction]()
方法。
在那里你应该放这样的东西:
$this->arguments['appointment']
->getPropertyMappingConfiguration()
->forProperty('students.*')
->allowAllProperties();
这将告诉 PropertyMapper 对 'students' 集合 属性 不严格。