我有一個包含這種形式的元件:如何在搜索表單元素的同一頁面上顯示搜索結果?
<?php
echo $this->Form->create('PrototypeItem', array(
'url' => array('instance' => $instance['PrototypeInstance']['slug'])
, 'class' => 'simple-search'
, 'action' => '/search'
));
echo $this->Form->input('search', array(
'label' => 'Search',
'type' => 'text'
));
echo $this->Form->end('Search');
?>
<!-- code for displaying search results here -->
此前,該元素被稱爲位於site.com/realtor-documents/search頁面上,它工作得很好。
但是,設計師要求我將搜索表單移至site.com/realtor-文檔,以消除額外的點擊。所以表格現在在/ realtor-documents,但是當我提交時,它仍然會重定向到/ realtor-documents/search。我希望結果與表單/ realtor-documents一樣顯示在同一頁面上。我怎樣才能做到這一點?
不太熟悉php,但我會建議通過ajax調用你的腳本/結果 – Mark
如果你在這個頁面中搜索,請刪除'action'=>'/ search' – tungbk29
你是否使用https://github.com/ CakeDC /搜索?如果沒有,你應該。 – mark