Temat: named parameters i $this->Form
Pewnie formularz ma służyć do filtrowania wyników.
Ja zwykle robię mniej więcej tak:
1. Widok:
echo $this->Form->create('Page') + echo $this->Form->text('state')
2. Kontroler:
if (!empty($this->request->data['Page'])) {
$redirect = array('action' => 'index');
if (!empty($this->request->data['Page']['state'])) {
$redirect['state'] = $this->request->data['Page']['state'];
}
$this->redirect($redirect);
}
3. Kontroler:
$conditions = array();
if (!empty($this->request->params['named']['state'])) {
$conditions['Page.state'] = $this->request->params['named']['state'];
$this->request->data['Page']['state'] = $this->request->params['named']['state']; //wypełnione pole formularza w momencie pokazywania wyników
}
4. Kontroler:
$this->Paginator->settings = array(
'conditions' => $conditions
);
$pages = $this->Paginator->paginate('Page');
5. Routes:
Router::connectNamed(array('state'), array('default' => true));
6. Widok:
$this->Paginator->options(array('url' => $this->request->params['named']));
A reszta stronnicowania standardowo