Bug #33628

Multicheckboxes (multiselect) for Collections don’t work

Added by Kira Backes about 9 years ago. Updated almost 9 years ago.

Status:
Needs Feedback
Priority:
Must have
Category:
ViewHelpers
Target version:
-
Start date:
2012-02-02
Due date:
% Done:

0%

Estimated time:
Has patch:
No

Description

Let’s say I have a search and there are 20 categories which are selectable (I can select one, three or even all of them) then I would like all selected categories to be loaded into a collection, so I can search in those categories. For this use-case there is the following code:

Action

    /**
     * Submit search action
     *
     * @param \Doctrine\Common\Collections\ArrayCollection<\Package\Name\Domain\Model\Category> $categories
     * @return void
     */
    public function submitSearchAction(\Doctrine\Common\Collections\ArrayCollection $categories) {

Template

        <f:for each="{categories}" as="category" iteration="it">
            <div style="width: 300px; float: left;">
                <f:form.checkbox  id="category{it.cycle}" name="categories[]" value="{category}" />
                <label for="category{it.cycle}"><f:translate>{category.name}</f:translate></label>
            </div>
        </f:for>

Now the problem is that the CheckBoxViewHelper always renders an empty hidden field with an empty value for check boxes. Due to this hidden field with an empty value FLOW3 tries to load the Category with the persistence identifier of "", which throws an exception. When I remove the hidden field (in a hacky way) then everything works as expected.

#1297759968: Exception while property mapping at property path "0": Object with identity "" not found.

Nested Exception
#1297933823: Object with identity "" not found.
TYPO3\FLOW3\Property\Exception\TargetNotFoundException

Related issues

Related to TYPO3.Fluid - Bug #26481: hidden fields should be rendered in extra sectionResolvedBastian Waidelich2011-04-29

Actions
Related to TYPO3.Fluid - Bug #36662: Checked state isn't always correct when property is collectionNeeds FeedbackKevin Ulrich Moschallski2012-04-27

Actions

Also available in: Atom PDF