typo3view-helpers

usign foreign model in own viewhelper as argument


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!


Solution

  • 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.