Sunday, March 21, 2010

Custom filter query in symfony 1.4

This cracked my head in this wee hour. Thankfully I got it working.

# add the custom field in myapp/modules/client/config/generator.yml
display: [ existing_fields, paid_up_cap_more]
paid_up_cap_more: { label: Paid up capital (RM) - more than }

// in lib/filter/doctrine
class CrmClientFormFilter extends BaseCrmClientFormFilter
public function configure() {
$this->widgetSchema['paid_up_cap_more'] = new sfWidgetFormInput();
$this->validatorSchema['paid_up_cap_more'] = new sfValidatorPass(array ('required' => false));

public function getFields() {
$fields = parent::getFields();
$fields['paid_up_cap_more'] = 'paid_up_cap_more';
return $fields;

// must be in this format addXXXXXColumnQuery
protected function addPaidUpCapMoreColumnQuery($q, $element, $value) {
if (!empty($value)){
$q->andWhere('paid_up_capital >= ?', $value);
return $q;


  1. Hi man im strugling with this issue for more than 2h now. cant get this working. Im using propel though but still i get: LogicExceptionCannot update form fields.marking the error in this very first line $this['alquilado']= new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')));im going to keep trying but i dont seem to be near fixing it if the error comes out with what is the most basic line.i modified the getFields. tried with: $fields=parent::getFields(); $fields['alquilado']='alquilado'; return $fields;and : $fields=parent::getFields(); $fields['alquilado']='Boolean'; return $fields;any ideas?

  2. for get it stupidest error ever i forgot it was : $this->widgetSchema['alquilado']=new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')));