CakePHP 3.4 - 调用setTemplates()的数组到字符串转换警告

时间:2017-02-20 16:07:55

标签: php cakephp-3.4

我需要更改包装div上的CSS类名称,因此尝试使用CakePHP book中的setTemplates示例。

我刚从示例中复制并粘贴了以下几行:

$myTemplates = [ 'inputContainer' => '<div class="form-control">{{content}}</div>', ]; $this->Form->setTemplates($myTemplates);

运行代码后,我不断收到Array to string conversion警告。代码仍然有效,但是这个警告很烦人,因为它打开了调试,打破了布局。由于这个愚蠢的警告,我不想关闭调试。关于如何摆脱它的任何提示?

修改

根据建议,这里是stacktrace:

include - APP/Template\Layout\default.ctp, line 49
Cake\View\View::_evaluate() - CORE\src\View\View.php, line 1010
Cake\View\View::_render() - CORE\src\View\View.php, line 971
Cake\View\View::renderLayout() - CORE\src\View\View.php, line 642
Cake\View\View::render() - CORE\src\View\View.php, line 600
Cake\Controller\Controller::render() - CORE\src\Controller\Controller.php, line 623
App\Controller\PagesController::display() - APP/Controller\PagesController.php, line 61
Cake\Controller\Controller::invokeAction() - CORE\src\Controller\Controller.php, line 440
Cake\Http\ActionDispatcher::_invoke() - CORE\src\Http\ActionDispatcher.php, line 119
Cake\Http\ActionDispatcher::dispatch() - CORE\src\Http\ActionDispatcher.php, line 93
Cake\Http\BaseApplication::__invoke() - CORE\src\Http\BaseApplication.php, line 78
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Routing\Middleware\RoutingMiddleware::__invoke() - CORE\src\Routing\Middleware\RoutingMiddleware.php, line 59
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Routing\Middleware\AssetMiddleware::__invoke() - CORE\src\Routing\Middleware\AssetMiddleware.php, line 88
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Error\Middleware\ErrorHandlerMiddleware::__invoke() - CORE\src\Error\Middleware\ErrorHandlerMiddleware.php, line 93

完成警告:

Notice (8): Array to string conversion [APP/Template\Layout\default.ctp, line 49]
第49行:

'inputContainer' => '<div class="form-control">{{content}}</div>'

0 个答案:

没有答案