doukun1450 2015-02-07 09:35
浏览 39

使用typo3将对象从视图传递到控制器6.2.9

I faced the following problem in Typo3 6.2.9:

When I pass some objects to the controller by using f:link action and arguments, the objects will arrive at the controller but he does not register them as they what I have send. For a better explanation here the single code sections:

at the partial:

<f:link.action action="new" controller="ForeignProductMeasuring" arguments="{planRow : planRow, plan:plan}">neue Dosierung anlegen</f:link.action>

the generated link in the site:

"index.php?id=1&tx_desinfektionsplan_desinfektionsplan%5BplanRow%5D=12&tx_desinfektionsplan_desinfektionsplan%5Bplan%5D=16&tx_desinfektionsplan_desinfektionsplan%5Baction%5D=new&tx_desinfektionsplan_desinfektionsplan%5Bcontroller%5D=ForeignProductMeasuring&cHash=2adafaba9c56b134d4d5ae382ee5d57b"

what shows the the arguments are correct in my opinion.

Here the action at the controller:

public function newAction(\Orochemie\Desinfektionsplan\Domain\Model\ForeignProductMeasuring $newForeignProductMeasuring = NULL,
\Orochemie\Desinfektionsplan\Domain\Model\PlanRow $planRow,
\Orochemie\Desinfektionsplan\Domain\Model\Plan $plan) {

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump( $this->request->getArguments());
$this->view->assign('newForeignProductMeasuring',$newForeignProductMeasuring);
$this->view->assign('planRow', $planRow);
$this->view->assign('plan', $plan);

}

The error looks like this:

#1: PHP Catchable Fatal Error: Argument 2 passed to
Orochemie\Desinfektionsplan\Controller\ForeignProductMeasuringController::newAction()
must be an instance of Orochemie\Desinfektionsplan\Domain\Model\PlanRow, 
none given in /kunden/137629_70806/typo3/typo3conf/ext/desinfektionsplan/Classes/Controller/ForeignProductMeasuringController.php line 46

For me it looks like that he doesn't knows the objects which he gets. But if I check the arguments with $this->request->getArguments() then I see that all arguments arrive at the controller.

Does anybody has a idea of what is the problem here?

  • 写回答

1条回答 默认 最新

  • douyuanliao8815 2015-02-09 00:09
    关注

    Did you define your params in the PHPDoc annotations?

    /**
     * @param \Orochemie\Desinfektionsplan\Domain\Model\ForeignProductMeasuring newForeignProductMeasuring
     * @param \Orochemie\Desinfektionsplan\Domain\Model\PlanRow $planRow
     * @param \Orochemie\Desinfektionsplan\Domain\Model\Plan $plan
     * @return void
     */
     public function newAction(\Orochemie\Desinfektionsplan\Domain\Model\ForeignProductMeasuring $newForeignProductMeasuring = NULL,
        \Orochemie\Desinfektionsplan\Domain\Model\PlanRow $planRow,
        \Orochemie\Desinfektionsplan\Domain\Model\Plan $plan) {
    
        ...
    
    }
    

    These are pretty important for the ObjectMapper.

    评论

报告相同问题?

悬赏问题

  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染