0
votes

From fluid, I call my viewhelper-class <ext:thehelper adr="{adr}" /> {adr} is an array of tt_address → FriendsOfTYPO3\TtAddress\Domain\Model\Address

in the viewhelper I register the argument

    use FriendsOfTYPO3\TtAddress\Domain\Model\Address;
    public function initializeArguments() {
        $this->registerArgument('adr', 'FriendsOfTYPO3\TtAddress\Domain\Model\Address', 'the addresses', true);
    }

this fails with this message: The argument "adr" was registered with type "FriendsOfTYPO3\TtAddress\Domain\Model\Address", but is of type "TYPO3\CMS\Extbase\Persistence\Generic\QueryResult" in view helper

How can I receive the adr-array to work with. Thank You for your help!

1
in the controller you can pass address as array to the view: $this->view->assign('adr', $address->toArray());. - David
I try this without controller. Just a viewhelper and tt_address templating. I tryed to adopt the help with "use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;" , Bad try. what class I am missing? - Eumolpius
then you've to accept \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult as argument in the viewhelper: $this->registerArgument('adr', 'TYPO3\CMS\Extbase\Persistence\Generic\QueryResult', 'the addresses', true); } - David
You can convert the object to an array then afterwards if required. - David

1 Answers

1
votes

If your VH must accept multiple addresses then your ViewHelper argument must not register the class name of whichever object is contained within a query result, as data type.

Instead you must register the argument with type TYPO3\CMS\Extbase\Persistence\Generic\QueryResult.