typo3fluidtypo3-9.xview-helpers

"Undeclared arguments passed to ViewHelper" Exception


After updating TYPO3, I get a TYPO3Fluid\Fluid\Core\ViewHelper\Exception "Undeclared arguments passed to ViewHelper ... Valid arguments are."


Solution

  • Tip: Use rector to make these (and other) conversions! Functions for TYPO3 are available, see


    This may be due to an extension using functionality that has been dropped. Using only the TYPO3 core, you should not see this error.

    In your extension: If you still use the render() method in your ViewHelper class with arguments, you may want to replace this:


    before:

    public function render(Mail $mail, $type = 'web', $function = 'createAction')
    

    after:

    public function initializeArguments()
    {
        parent::initializeArguments();
    
        $this->registerArgument('mail', Mail::class, 'Mail', true);
        $this->registerArgument('type', 'string', 'type: web | mail', false, 'web');
        $this->registerArgument('function', 'string', 'function: createAction | senderMail | receiverMail', false, 'createAction');
    }
    
    public function render()
    {
        $mail = $this->arguments['mail'];
        $type = $this->arguments['type'] ?? 'web';
        // ...  
    
    }
    

    Additionally,

    // use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
    use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
    

    Documentation:

    Changelogs: