Passing data from CakePHP component to a helper

前端 未结 3 1877
萌比男神i
萌比男神i 2020-12-18 10:27

I need to share data between a component and helper. I\'m converting my self-made payment service formdata generator to a CakePHP plugin and I\'d like to be able to fill in

3条回答
  •  攒了一身酷
    2020-12-18 10:50

    In addition to what @Vanja, you can also do this just prior to instantiating a new view in your controller:

    // In your controller method
    // must be set prior to instantiating view
    $this->helpers['YourHelperName']['paramsOrAnyName'] = ['var' => $passed_var];
    
    $_newView = new View($this);
    $return_result = $_newView->render($element_to_view, $layout);
    

提交回复
热议问题