I am trying to search a model by dates using the CakePHP Search plugin
The idea is: The user enters a date of a flight and the engine returns all flights within +- one day of that.
My form:
<?php
echo $form->create('Flight', array(
'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));
echo $form->input('departure', array('div' => false, 'dateFormat' => 'DMY','timeFormat' => 'NONE'));
echo $form->submit(__('Search', true), array('div' => false));
echo $form->end();
?>
My flight model:
public $filterArgs = array(
array('name' => 'departure', 'type' => 'expression', 'method' => 'makeRangeCondition', 'field' => 'ABS((TO_Days(Flight.departure))-( TO_Days(?))) < 2')
);
The controller:
public $presetVars = array(
array('field' => 'departure', 'type' => 'expression')
);
public function find() {
$this->Prg->commonProcess();
$this->paginate['conditions'] = $this->Flight->parseCriteria($this->passedArgs);
$this->set('flights', $this->paginate());
}
When I try to search, the values for departure are packed in an array;
Array ([departure] => Array )
And the filterArgs(...) function doesn't seem to understand this. What is the correct way to do this?