php - Symfony 1.4 filter doesn't work -
i have problem filters in symfony 1.4 (module created admin generator)
<?php abstract class basetestformfilter extends baseformfilterdoctrine { public function setup() { $this->setwidgets(array( 'country' => new sfwidgetformchoice(array('choices' => $this->getchoicesbyfield('country'))), 'currency' => new sfwidgetformchoice(array('choices' => $this->getchoicesbyfield('currency'))), )); $this->setvalidators(array( 'country' => new sfvalidatorpass(array('required' => false)), 'currency' => new sfvalidatorpass(array('required' => false)), )); $this->widgetschema->setnameformat('economiccalendar_filters[%s]'); $this->errorschema = new sfvalidatorerrorschema($this->validatorschema); $this->setupinheritance(); parent::setup(); } private function getchoicesbyfield($field){ $q = doctrine_query::create() ->select("t.$field") ->from('test t') ->groupby("$field") ->execute(); $query_result = $q->toarray(); $result = array(); foreach ($query_result $val) { $result[$val[$field]] = $val[$field]; } return $result; } public function getmodelname() { return 'test'; } public function getfields() { return array( 'country' => 'text', 'currency' => 'text', ); } }
so have 2 filter fields looks selects. problem populating, when try filter, don't filter nothing, data same, out them. apreciate help.
so problem - needed add method
public function addcountrycolumnquery($query, $field, $value) { if (!empty($value)) { $query->andwherein('country', $value); } }
with out method, query filtered values don't values, need.
Comments
Post a Comment