简体   繁体   中英

TYPO3 ExtBase - Required argument X is not set

I try to modify the extension importr to insert a custom action to the controller "Importr" at importr\\Classes\\Controller\\ImportrController.php .

I called the action "customAction" and reference to it from a button which I render with fluid in importr\\Resources\\Private\\Templates\\Importr\\Index.html by using <f:link.action>

<div id="myButton">
  <f:link.action 
      extensionName="Importr" 
      pluginName="Importr" 
      controller="Importr" 
      action="custom" 
      arguments="{taskid:5}"
  >
    Click here
  </f:link.action>
</div>

controller action:

/**
 * @param int $taskid
 * @return void
 */
public function customAction($taskid)
{
    ...
}

However, every attempt to pass a parameter to the action fails. At my first attempt I even get an error page without even clicking on the button as you can see in the screenshot below.


Attempt #1

/**
 * @param int $taskid
 * @return void
 */
public function customAction($taskid)
{
    print_r($taskid);
    die;
}

Uncaught TYPO3 Exception

1298012500: Required argument "taskid" is not set for HDNET\\Importr\\Controller\\ImportrController->custom.

TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Exception\\RequiredArgumentMissingException thrown in file /var/www/typo3/typo3_src-6.2.25/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php in line 425.'

进口商


Attempt #2

/**
 * @return void
 */
public function customAction()
{           
    $taskid = "default";

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

    echo "TASKID = '$taskid'";
    die;
    ...

OUTPUT : TASKID = 'default'


Attempt #3:

/**
     *  @return void
 */
public function customAction()
{
        $args = $this->request->getArguments();
        $taskid = $args['taskid'];

        echo "TASKID = '$taskid'";
        die;

OUTPUT: TASKID = ''

I don't know what else I can try. Is it possible that I made a mistake in the Fluid Code? Do I use a wrong pluginName or extensionName or is it even a typo3 bug? Where is the pluginName stored so I can check it?



More Infos

I allowed my custom action by adding it to the other actions inside ext_tables.php

<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}

/** @var string $_EXTKEY */

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
    'HDNET.' . $_EXTKEY,
    'file',
    'tx_importr_mod',
    '',
[
    'Importr' => 'custom,index,import,preview,create',
],
[
    'access' => 'user,group',
    'icon' => 'EXT:' . $_EXTKEY . '/ext_icon.gif',
    'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xlf'
]);

There were two problems:

1. ext_tables.php

The order of the actions was not correct. The first action is always the default action, so it took my custom action as default action and therefor no page was loaded after clicking on the Importr Modul in the menu at the left. It worked after I corrected it.

'Importr' => 'index,import,preview,create,custom',

2. Fluid

The pluginName was incorrect, the correct pluginName is file_importrtximportrmod , which we can see in ext_tables.php

It is not even needed, it also works if you omit pluginName and extensionName.

Make sure to clear the cache in the install tool afterwards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM