3

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

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49

2 Answers2

12

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,

  • if there is no need to use render() (e.g. unless you need to access $this variables), you may want to switch to renderStatic() for performance reasons (see also this other Stack Overflow answer "What is the difference between render() and renderStatic() ..." for clarification)
  • inherit from classes in TYPO3Fluid\Fluid\Core\ViewHelper instead of TYPO3\CMS\Fluid\Core\ViewHelper:
// use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

Documentation:

Changelogs:

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49
0

You are using other extension that makes this error, for example: https://github.com/lochmueller/calendarize/issues/280

If you have a parameters in a ViewHelper, you send them as arguments from Fluid Template. In TYPO3 this error throws when in render() function not have comments about parameters. You have to include them.

Example:

<?php

namespace VENDOR\ExtensionName\ViewHelpers;

class ExampleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
{

 /**
  * 
  * @param int $foo
  * @return boolean
  */
 public function render($foo) {
     //function render lines    
     return $bar_boolean;
 }
}
César Dueñas
  • 331
  • 4
  • 18