search

Home  >  Q&A  >  body text

TYPO3 V11: "PHP warning: undefined array key", $this->request->getArguments() is empty

I'm a new user of typo3, I made a plugin to display users and use the search bar to filter them, but when I want to display my page I get this error:

(1/1) #1476107295 TYPO3CMSCoreErrorException
PHP Warning: Undefined array key "word" in MyPath/Controller/UserlistController.php line 44

In my controller I try to get the parameter to use it in my filter like this:

public function listAction(int $currentPage = 1)
{
   $arguments = $this->request->getArguments();
   $users = $this->userlistRepository->findBySearch($arguments['word'] ? $arguments['word'] : '');

somecode ...

}

I tried dumping $arguments but it was empty

There is a section in my repository:

/**
     * @param string $word
     * @return object[]|TYPO3CMSExtbasePersistenceQueryResultInterface
     * @throws TYPO3CMSExtbasePersistenceExceptionInvalidQueryException
     */
    public function findBySearch(string $word) {
        $query = $this->persistenceManager->createQueryForType(TYPO3CMSExtbaseDomainModelFrontendUser::class);
        $querySettings = $query->getQuerySettings();
        $querySettings->setStoragePageIds([26]);
        $query->setQuerySettings($querySettings);

        $query->setOrderings([
            'lastName' => QueryInterface::ORDER_ASCENDING
        ]);

Does anyone know why I can't get the parameters? Thanks

If you need more parts of the code, please let me know

P粉807471604P粉807471604397 days ago1004

reply all(1)I'll reply

  • P粉817354783

    P粉8173547832023-11-13 18:55:40

    If you just call the List operation without sending the filter form, the parameter is empty.

    You should test each expected parameter before accessing it, like this:

    if($this->request->hasArgument('word')) {
            $searchOption = $this->request->getArgument('word'));
    }

    reply
    0
  • Cancelreply