의견을 보내 주셔서 감사합니다. 내가 가지고있는 문제는 내 사용자 정의 필터의 값에 액세스하여 표시된 열을 변경하는 데 사용할 수있는 문제였습니다.결국, 이것이 내가 이룬 방법입니다.
내 FormFilter 클래스에서 사용자 정의 위젯을 구성하고 유효성 검사기를 추가했습니다. 이로 인해 값을 처리하기위한 메서드 (% sColumnQuery 추가)가 추가되었습니다. 값을 사용자 개체에 추가하여 다른 곳에서 검색하기 위해 값을 저장했습니다. 일반적으로이 메서드는 쿼리를 변경하는 데 사용됩니다. 아래를 참조
class ExpenditureFormFilter extends BaseExpenditureFormFilter
{
public function configure()
{
parent::configure();
$years = range((int)date("Y", strtotime(sfConfig::get('app_view_min_period'))), (int)date("Y", strtotime(sfConfig::get('app_view_max_period'))));
$this->widgetSchema['start_period'] = new sfWidgetFormDate(array(
'format' => '%month%/%year%',
'can_be_empty' => false,
'months' => array_combine(range(1, 12), array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')),
'years' => array_combine($years, $years)
));
$this->widgetSchema->setLabels(array(
'start_period' => 'Start period',
));
$this->validatorSchema['start_period'] = new sfValidatorMonthYear(
array(
'min' => strtotime(sfConfig::get('app_view_min_period')),
'max' => strtotime(sfConfig::get('app_view_main_period'))
),
array(
'required' => true
)
);
}
public function getFields()
{
$fields = parent::getFields();
$fields['start_period'] = 'Date';
return $fields;
}
protected function addStartPeriodColumnQuery($query, $field, $value)
{
sfContext::getInstance()->getUser()->setAttribute('start_period', $value);
}
}
내가 다음 오버라이드 자동 생성 _list_td_tabular.php (쉽게 모듈 템플릿 디렉토리에 같은 이름의 복사본을 생성하여 바로 수행),이 내 나는 사용자가 액세스 할 수 있었던 부분 객체, 따라서 내 필터 값과 같이 : 그래서
$start_period = sfContext::getInstance()->getUser()->getAttribute('start_period');
지금은 동적 목록 템플릿에 표시 할 열을 생성하기 위해이 값을 사용 할 수 있어요 - 임무 :
을 달성 I가 사랑 물론 더 좋은 방법이 있는지 아세요? 이것은 나를 위해 일한다!
안부,
매트.