我需要更改包装 div 上的 CSS 类名称,因此尝试使用CakePHP booksetTemplates
中的示例。
我刚刚从示例中复制并粘贴了以下几行:
$myTemplates = [
'inputContainer' => '<div class="form-control">{{content}}</div>',
];
$this->Form->setTemplates($myTemplates);
运行代码后,我不断收到Array to string conversion
警告。该代码仍在工作,但是该警告很烦人,因为它在打开调试的情况下破坏了布局。我不想因为那个愚蠢的警告而关闭调试。关于如何摆脱它的任何提示?
编辑
根据这里的建议是堆栈跟踪:
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>'