<?php

/**
 * Session filter form base class.
 *
 * @package    sf
 * @subpackage filter
 * @author     Atma
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseSessionFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'session_data' => new sfWidgetFormFilterInput(),
      'session_time' => new sfWidgetFormFilterInput(),
      'user_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'token'        => new sfWidgetFormFilterInput(),
      'device_id'    => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'session_data' => new sfValidatorPass(array('required' => false)),
      'session_time' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'user_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('User'), 'column' => 'id')),
      'token'        => new sfValidatorPass(array('required' => false)),
      'device_id'    => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('session_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Session';
  }

  public function getFields()
  {
    return array(
      'id'           => 'Text',
      'session_data' => 'Text',
      'session_time' => 'Number',
      'user_id'      => 'ForeignKey',
      'token'        => 'Text',
      'device_id'    => 'Text',
    );
  }
}
