<?php

/**
 * User form base class.
 *
 * @method User getObject() Returns the current form's model object
 *
 * @package    mongolcom
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'username'     => new sfWidgetFormInputText(),
      'lastname'     => new sfWidgetFormInputText(),
      'firstname'    => new sfWidgetFormInputText(),
      'type'         => new sfWidgetFormInputText(),
      'role'         => new sfWidgetFormInputText(),
      'org_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Organization'), 'add_empty' => false)),
      'pass_rd'      => new sfWidgetFormInputText(),
      'is_active'    => new sfWidgetFormInputText(),
      'is_close'     => new sfWidgetFormInputText(),
      'password'     => new sfWidgetFormInputText(),
      'email'        => new sfWidgetFormInputText(),
      'gender'       => new sfWidgetFormInputText(),
      'birthday'     => new sfWidgetFormDate(),
      'image'        => new sfWidgetFormInputText(),
      'description'  => new sfWidgetFormTextarea(),
      'phone'        => new sfWidgetFormInputText(),
      'created_at'   => new sfWidgetFormDateTime(),
      'last_seen_at' => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'username'     => new sfValidatorString(array('max_length' => 255)),
      'lastname'     => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'firstname'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'type'         => new sfValidatorInteger(),
      'role'         => new sfValidatorInteger(),
      'org_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Organization'))),
      'pass_rd'      => new sfValidatorString(array('max_length' => 10)),
      'is_active'    => new sfValidatorInteger(),
      'is_close'     => new sfValidatorInteger(),
      'password'     => new sfValidatorString(array('max_length' => 255)),
      'email'        => new sfValidatorString(array('max_length' => 255)),
      'gender'       => new sfValidatorInteger(array('required' => false)),
      'birthday'     => new sfValidatorDate(array('required' => false)),
      'image'        => new sfValidatorString(array('max_length' => 255)),
      'description'  => new sfValidatorString(array('required' => false)),
      'phone'        => new sfValidatorInteger(array('required' => false)),
      'created_at'   => new sfValidatorDateTime(),
      'last_seen_at' => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'User';
  }

}
