我有一个方法,它执行搜索并将结果发送到它的视图。搜索结果仅在分页结果的第一页上可用。随后的分页页面没有数据,并且有关于无效索引/变量的警告/错误:
控制器
public function show_list ()
{
$i_state_id = $this->data['Contact']['state_id'];
$str_city = $this->data['Contact']['city'];
$this->Contact->recursive = -1;
$this->paginate = array (
'conditions' => array ('Contact.state_id' => $i_state_id, 'Contact.city'=> $str_city),
'fields' => array('Contact.id', 'Contact.name', 'Contact.mobile1', 'Contact.city'),
'order' => array ('Contact.id' => 'desc'),
'limit' => 2,
'recursive' => -1
);
$contacts = $this->paginate('Contact');
$this->set ('contacts', $contacts);
$this->set('state_id', $i_state_id);
$this->set('city', $str_city);
}
查看 (show_list.ctp)
<div class="contacts index">
<h2><?php echo __('Select the list of contacts, that you wish to move.'); ?></h2>
<?php echo $this->Form->create('Contact',array('action'=>'add_contacts_to_user'));?>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Form->checkbox('all', array('label'=>"Select All", "onclick" =>"toggleChecked(this.checked)" )); ?></th>
<th><?php echo $this->Paginator->sort('name'); ?></th>
<th><?php echo $this->Paginator->sort('Contact Info'); ?></th>
<th><?php echo $this->Paginator->sort('city'); ?></th>
</tr>
<?php
foreach ($contacts as $contact): ?>
<tr>
<td><?php echo h($contact['Contact']['id']); ?> </td>
<td><?php echo $this->Form->checkbox('Contact.id.'.$contact['Contact']['id'], array('class' => 'checkbox', 'value'=> $contact['Contact']['id'],'hiddenField' => false)); ?></td>
<td><?php echo h($contact['Contact']['name']); ?> </td>
<td><?php echo h($contact['Contact']['mobile1']); ?> </td>
<td><?php echo h($contact['Contact']['city']); ?> </td>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php
echo $this->Form->end("Move to Address Book");
?>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?> </p>
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>
</div>
如何让第二个和后续页面显示搜索页面的结果?