Skip to content

Instantly share code, notes, and snippets.

@jmather
Created April 29, 2011 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmather/948931 to your computer and use it in GitHub Desktop.
Save jmather/948931 to your computer and use it in GitHub Desktop.
<?php
/**
* Photo filter form.
*
* @package cms
* @subpackage filter
* @author JMather
* @version SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class PhotoFormFilter extends BasePhotoFormFilter
{
public function configure()
{
unset($this['image_file_id'], $this['content'], $this['content_html']);
$this->setWidget('areas_list', new dcmsWidgetFormPreferencePoweredAreaSelect(array('label' => 'Published To')));
$this->setValidator('areas_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'Area', 'required' => false)));
}
public function addAreasListColumnQuery(Doctrine_Query $query, $field, $values)
{
if (!is_array($values))
{
$values = array($values);
}
if (!count($values))
{
return;
}
$query
->leftJoin($query->getRootAlias().'.ContentRegistryEntry ContentRegistryEntry')
->leftJoin('ContentRegistryEntry.AreaContentRegistryEntry AreaContentRegistryEntry')
->andWhereIn('AreaContentRegistryEntry.area_id', $values)
;
}
public function getFields()
{
$fields = parent::getFields();
$fields['areas_list'] = 'ManyKey';
return $fields;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment