views:

125

answers:

1

Below I have pasted code snippets of a page where it displays cars by year and model. This list is paginated. For this example, imagine that you go to page 5 of the list displayed. At the bottom of the page, there is a form that lets you refine your search. When you fill in another year and model and push "Search", it reloads the page with a new list of cars and years. The issue is that when you submit the form and the page reloads, the displayed content is on page 5 of the new search. How do I get the form submit to show the new search at page 1. I think one possible cause is that the url has "../search/page:5" in it when you try to submit the form:

$paginator->options(array('url' =>  array($condition_string)));
echo $paginator->sort('Year', 'Car.year', array('url' => array('page' => 1)));
echo $paginator->sort('Model', 'Car.model', array('url' => array('page' => 1)));

//table code that displays years and models

echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
echo $paginator->numbers();
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));

//form that submits new search
echo $form->create('Car', array('action' => 'search'));
echo $form->input('model');
echo $form->input('year');
echo $form->end('Search');
A: 

try using the "url"-option of the form-helper, like:

<?= $form->create('Car',array('url' => '/.../search')) ?>

EDIT (quick n' dirty fix):

<form action=".../search" method="post">
<input type="text" name="data[Car][model]" />
<input type="text" name="data[Car][year]" />
<?=$form->end("Search")?>
dale
that didn't seem to do anything. the url still stays the same even though it loads the new search on page 5. Perhaps I need to tell the $paginator->sort to do something about the page?
Hooman Ahmadi
Seems wierd, an easy fix is to write the form using HTML. Atleast then cake wont fuck up the action-url. See edit above
dale