/View/Layouts/default.ctp (サイトのホームページ プレゼンテーション レイアウト) に HTML 入力フォーム (検索バー) を埋め込みたい。/View/Elements/lookup.ctp を次のコードで作成しました (サイトのすべてのページにその検索バーを含めたかったので、Element を作成しました)。
<?php
echo $this->Form->create('Search', array('action' => 'lookup', 'accept-charset' => 'utf-8'));
echo $this->Form->input(array('type' => 'search', 'name' => 'search', 'placeholder' => 'enter search term'));
echo $this->Form->button('Search', array('type' => 'button', 'value' => 'submit'));
echo $this->Form->end();
?>
検索バー自体は次のようになります。
___________________________ ______________
| enter search term | | Search | <--- button
|_________________________| |______________|
↑
search bar
/View/Layouts/default.ctp に生成されたコードは次のようになります。
<form id="searchForm" method="post" action="/searches/lookup" accept-charset="utf-8">
<input type="search" name="search" placeholder="enter search term" />
<button type="button" name="submit" value="submit">Search</button>
</form>
私は行を含めました:
<?php echo $this->element('lookup'); ?>
/View/Layouts/default.ctp (要素を埋め込んでいます) にありますが、ホームページに移動すると、この要素がレンダリングされず、エラーが表示されます。
( @Wylie: はい、その通りです。エラー全体ではありません。ここに完全なエラーがあります)
#0 C:\wamp\www\lib\Cake\Model\Datasource\DboSource.php(436): PDOStatement->execute(Array)
#1 C:\wamp\www\lib\Cake\Model\Datasource\Database\Mysql.php(307): DboSource->_execute('SHOW FULL COLUM...')
#2 C:\wamp\www\lib\Cake\Model\Model.php(1226): Mysql->describe(Object(Search))
#3 C:\wamp\www\lib\Cake\View\Helper\FormHelper.php(197): Model->schema()
#4 C:\wamp\www\lib\Cake\View\Helper\FormHelper.php(450): FormHelper->_introspectModel('Search', 'fields')
#5 C:\wamp\www\azil\View\Elements\lookup.ctp(2): FormHelper->create('Search', Array)
#6 C:\wamp\www\lib\Cake\View\View.php(595): include('C:\wamp\www\azi...')
#7 C:\wamp\www\lib\Cake\View\View.php(317): View->_render('C:\wamp\www\azi...', Array)
#8 C:\wamp\www\azil\View\Layouts\default.ctp(91): View->element('lookup')
#9 C:\wamp\www\lib\Cake\View\View.php(595): include('C:\wamp\www\azi...')
#10 C:\wamp\www\lib\Cake\View\View.php(411): View->_render('C:\wamp\www\azi...')
#11 C:\wamp\www\lib\Cake\View\View.php(373): View->renderLayout('<h2>Database ta...', 'default')
#12 C:\wamp\www\lib\Cake\Controller\Controller.php(900): View->render('error500', NULL)
#13 C:\wamp\www\lib\Cake\Error\ExceptionRenderer.php(282): Controller->render('error500')
#14 C:\wamp\www\lib\Cake\Error\ExceptionRenderer.php(191): ExceptionRenderer->_outputMessageSafe('error500')
#15 [internal function]: ExceptionRenderer->_cakeError(Object(MissingTableException))
#16 C:\wamp\www\lib\Cake\Error\ExceptionRenderer.php(165): call_user_func_array(Array, Array)
#17 C:\wamp\www\lib\Cake\Error\ErrorHandler.php(127): ExceptionRenderer->render()
#18 [internal function]: ErrorHandler::handleException(Object(MissingTableException))
#19 {main} [<b>CORE\Cake\Error\ErrorHandler.php
テーブルがない?! /View/Layouts/default.ctp 内にいくつかの HTML 行を追加する必要があるだけです。何が起こっているのかわかりません。助けてください。ありがとうございました。