Typo3渲染FieldControl“參數(shù)太少”

我為零售商/商店數(shù)據(jù)庫構(gòu)建了一個Typo3插件。每個商店都應(yīng)該有經(jīng)緯度。為了不必手動輸入每個緯度和經(jīng)度,我添加了一個按鈕(在TCA中帶有fieldcontrol)來自動輸入數(shù)據(jù)。當(dāng)您首先保存存儲,然后檢索位置數(shù)據(jù)時,效果非常好。但在存錢之前這樣做會更方便。因此,我想通過ajax觸發(fā)數(shù)據(jù)導(dǎo)入。我在Typo3文檔中找到了這個例子:https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/FormEngine/Rendering/Index.html#add-fieldcontrol-example

現(xiàn)在我面臨一個顯然與ajax控制器有關(guān)的問題。我得到了以下錯誤:“函數(shù)Vendor\MyExt\Controller\Ajax\LocateAddressController::locateAddressAction()的參數(shù)太少,在第91行/.../typo3/sysext/backend/Classes/Http/RouteDispatcher.php中傳遞了1,正好需要2”

以下是我的代碼節(jié)選:LocateAddress.js:

/**
   * @param {int} id
   */
   LocateAddress.import = function (id) {
      $.ajax({
         type: 'POST',
         url: TYPO3.settings.ajaxUrls['locate-address'],
         data: {
            'id': id
         }
      }).done(function (response) {
         if (response.success) {
            top.TYPO3.Notification.success('Import Done', response.output);
         } else {
            top.TYPO3.Notification.error('Import Error!');
         }
      });
   };

AjaxRoutes.php:

return [
   'locate-address' => [
      'path' => '/locate-address',
      'target' => \Vendor\MyExt\Controller\Ajax\LocateAddressController::class . '::locateAddressAction'
   ],
];

LocateAddressController.php:

use Psr\Http\Message\ResponseInterface;
    use Psr\Http\Message\ServerRequestInterface;

    class LocateAddressController
    {
        /**
        * @param ServerRequestInterface $request
        * @param ResponseInterface $response
        * @return ResponseInterface
        */
        public function locateAddressAction(ServerRequestInterface $request, ResponseInterface $response)
        {
            $queryParameters = $request->getParsedBody();

            $response->getBody()->write(json_encode(['success' => true]));
            return $response;
        }

    }
? 最佳回答:

后端控制器(ResponseInterface $response)的第二個參數(shù)已被TYPO3 9棄用(請參閱文檔),并被TYPO3 v10刪除。extbase文檔中的示例似乎已經(jīng)過時。

只需刪除第二個參數(shù),并在方法中創(chuàng)建響應(yīng)對象以返回它。

public function locateAddressAction(ServerRequestInterface $request)
{
    ...
    return new JsonResponse(['success' => true]));
}
主站蜘蛛池模板: 久久精品人妻一区二区三区| 国产不卡视频一区二区三区| 亚洲Av无码国产一区二区| 精品深夜AV无码一区二区| 亚洲日本一区二区三区| 一区二区在线电影| 国产精品免费综合一区视频| 无码中文字幕乱码一区| 日韩在线观看一区二区三区| 一区二区三区视频免费| 国产在线视频一区二区三区 | 91精品一区二区综合在线| 八戒久久精品一区二区三区| 无码精品前田一区二区| 波多野结衣的AV一区二区三区| 国产波霸爆乳一区二区| 久久国产精品最新一区| 亚洲区精品久久一区二区三区| 波多野结衣一区二区三区| 亚洲精品日韩一区二区小说| 国产精品一级香蕉一区| 亚洲av成人一区二区三区观看在线 | 精品国产一区二区三区在线 | 国产精品一级香蕉一区| 国产综合无码一区二区辣椒| 在线精品自拍亚洲第一区| 亚洲日本一区二区| 国产一区二区免费| 香蕉在线精品一区二区| 日韩精品无码久久一区二区三| 亚洲国产成人久久一区二区三区| 精品人无码一区二区三区 | 无码国产精品一区二区高潮| 国产成人一区二区三区在线观看| 中文字幕一精品亚洲无线一区| 亚洲国产综合无码一区| 中文字幕日韩精品一区二区三区| 一区二区三区视频网站| 国产99久久精品一区二区| 色老板在线视频一区二区| 欧美成人aaa片一区国产精品|