F:widget.paginate throws Invalid Property Mapping Configuration Exception

(Thomas Grabietz) #1

Hello All,
I’m using NEOS 2.0.14 and have the following problem:
The f:widget.paginate iterates over a filtered QueryResultInterface. There is a little form above the paginate widget, which post filter statements to the Controller

 <f:form action="index" object="{filter}" objectName="filter">
    <label for="searchItem">Suche nach Vorkommen im Namen oder der eMail | Sortiere nach Datum</label>
    <f:form.textfield property="searchItem" id="searchItem" />
    <f:form.checkbox property="orderByRegistrationDate" value="true" id="orderByRegistrationDate" />
    <f:form.submit name="submit" value="Suche" />

This is the Controller

public function indexAction($filter)

        $filter = $filter === null ? new Filter() : $filter;

        $order = ($filter->orderByRegistrationDate === true) ? "accounts.creationDate" : "";

        $users = $this->userRepository->findByOrderBy($filter->searchItem, $order);

            'filter' => $filter,
            'statistic' => $this->usageStatistic,
            'users' => $users

And this the filter:

class Filter

     * @var string
    public $searchItem;

     * @var boolean
    public $orderByRegistrationDate = false;

The first paginated page is OK, but when I try to get the second page this error is thrown:

You need to use $propertyMappingConfiguration->allowProperties('orderByRegistrationDate') to enable mapping of this property.

Where must I “allow” or map this property?

Greetings, Tom

(Soren Malling) #2

You need to do this inside a initialize*Action - take a look at the documentation section Property mapping


Find the headline Property Mapping Configuration in the MVC stack

(Thomas Grabietz) #3

At the controller:

    protected function initializeAction()
        $propertyMappingConfiguration = $this->arguments['filter']->getPropertyMappingConfiguration();
        $propertyMappingConfiguration->allowProperties('orderByRegistrationDate', 'searchItem');

Thank you very much, problem solved :slight_smile: