我在 Symfony 1.4 中的过滤器有问题(由管理员生成器创建的模块)
<?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 as $val) {
$result[$val[$field]] = $val[$field];
}
return $result;
}
public function getModelName()
{
return 'Test';
}
public function getFields()
{
return array(
'country' => 'Text',
'currency' => 'Text',
);
}
}
所以我有 2 个看起来像选择的过滤器字段。问题是它们正在填充,当我尝试过滤但不过滤任何内容时,数据是相同的,就像没有它们一样。将感谢任何帮助。