Feature #49756

Select values by array key in checkbox viewhelper

Added by Simon Schaufelberger over 6 years ago. Updated over 5 years ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-07-07
Due date:
% Done:

0%

Has patch:
No

Description

my model:

class Model {
    protected $groups;

    public function getGroups() {
        $groups = array();
        foreach ($this->groups as $group) {
            $groups[\TYPO3\Flow\Reflection\ObjectAccess::getProperty($group, 'Persistence_Object_Identifier', TRUE)] = $group;
        }
        return $groups;
    }
}

my controller:

public function viewAction(\My\Package\Domain\Model\Member $member) {
    $groups = $this->groupRepository->findAll();
    $this->view->assign('member', $member);
    $this->view->assign('groupList', $groups);
}

my view:

<f:form action="editGroups" name="member" object="{member}">
    <f:for each="{groupList}" as="groupItem">
        <label class="checkbox inline">
            <f:form.checkbox property="groups" value="{groupItem -> f:format.identifier()}"/> {groupItem.name}
        </label>
    </f:for>
</f:form>

now what's not possible is to just assign the groups (a m:n-relation) to the checkbox because in the checkbox viewhelper the value is compared instead of the array key with in_array.

This patch also compares the array keys.

History

#1 Updated by Gerrit Code Review over 6 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22085

#2 Updated by Gerrit Code Review over 6 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22085

Also available in: Atom PDF