1
votes

I just checked and the html output seems to be the same for this in my working version back with TYPO3 4.7
I have an appointment that can have multiple students. I add them to a multi-select through an autocomplete textinput-field.

<input type="text" id="student-autocomplete"/>
<br/>
<f:form.select  id="selected-students" 
                multiple="true" 
                property="students"
                options="{appointment.students}" 
                optionLabelField="fullName"
                class="" />

This is the output - in this example I have added two students.
The input-hidden field seems to be automatically generated by 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>

Now what I really don't understand is: When I only have one student in my select it works, but when I have multiple I get following error:

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. 

I'm assuming the "1" refers to my second array index? But I have no idea what's wrong since it seems to work fine in TYPO3 4.7.
Should I do something with the new property mapper?
Should I try to change some things in my model?
:

/**
* 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;
}
1

1 Answers

2
votes

I can't tell the reason, why you see this exception, but you can try to make PropertyMapper a bit relaxed about this collection.

For that you need a initialize[yourAction]() method in same controller.

And there you should put something like this:

$this->arguments['appointment']
        ->getPropertyMappingConfiguration()
        ->forProperty('students.*')
        ->allowAllProperties();

This will tell PropertyMapper not to be strict about 'students' collection property.