<?php

/**
 * User form base class.
 *
 * @method User getObject() Returns the current form's model object
 *
 * @package    sf
 * @subpackage form
 * @author     Atma
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(array(), array()),
      'manager_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Manager'), 'add_empty' => true), array()),
      'city_id'               => new sfWidgetFormInputText(array(), array("size" => 10, "maxlength" => 10)),
      'username'              => new sfWidgetFormInputText(array(), array("size" => 32, "maxlength" => 128, "required" => true)),
      'fname'                 => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'iname'                 => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'oname'                 => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'organization'          => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'city'                  => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'inner_id'              => new sfWidgetFormInputText(array(), array("size" => 50, "maxlength" => 50)),
      'client_code'           => new sfWidgetFormInputText(array(), array("size" => 20, "maxlength" => 20, "required" => true)),
      'address'               => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'phone_number'          => new sfWidgetFormInputText(array(), array("size" => 25, "maxlength" => 100)),
      'email'                 => new sfWidgetFormInputText(array(), array("size" => 32, "maxlength" => 128)),
      'limit_by_sum'          => new sfWidgetFormInputText(array(), array("size" => 40, "maxlength" => 40)),
      'current_discount'      => new sfWidgetFormInputText(array(), array("size" => 40, "maxlength" => 40)),
      'current_debt'          => new sfWidgetFormInputText(array(), array("size" => 40, "maxlength" => 40)),
      'orders_sum_last_month' => new sfWidgetFormInputText(array(), array("size" => 40, "maxlength" => 40)),
      'orders_sum_current'    => new sfWidgetFormInputText(array(), array("size" => 40, "maxlength" => 40)),
      'salt'                  => new sfWidgetFormInputText(array(), array("size" => 32, "maxlength" => 128)),
      'password'              => new sfWidgetFormInputText(array(), array("size" => 32, "maxlength" => 128)),
      'open_password'         => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255)),
      'manifest_version'      => new sfWidgetFormInputText(array(), array("size" => 8, "maxlength" => 8)),
      'cat_indx'              => new sfWidgetFormTextarea(array(), array("rows" => 5, "cols" => 70)),
      'cats_with_images'      => new sfWidgetFormTextarea(array(), array("rows" => 5, "cols" => 70)),
      'recovery_secret'       => new sfWidgetFormTextarea(array(), array("rows" => 5, "cols" => 70)),
      'is_active'             => new sfWidgetFormInputCheckbox(array(), array()),
      'is_super_admin'        => new sfWidgetFormInputCheckbox(array(), array()),
      'last_login'            => new sfWidgetFormDateTime(array(), array()),
      'created_at'            => new sfWidgetFormDateTime(array(), array("required" => true)),
      'updated_at'            => new sfWidgetFormDateTime(array(), array("required" => true)),
    ));

    $this->setValidators(array(
      'id'                    => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'manager_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Manager'), 'required' => false)),
      'city_id'               => new sfValidatorInteger(array('required' => false)),
      'username'              => new sfValidatorString(array('max_length' => 128)),
      'fname'                 => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'iname'                 => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'oname'                 => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'organization'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'city'                  => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'inner_id'              => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'client_code'           => new sfValidatorString(array('max_length' => 20)),
      'address'               => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'phone_number'          => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'email'                 => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'limit_by_sum'          => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'current_discount'      => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'current_debt'          => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'orders_sum_last_month' => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'orders_sum_current'    => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'salt'                  => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'password'              => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'open_password'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'manifest_version'      => new sfValidatorInteger(array('required' => false)),
      'cat_indx'              => new sfValidatorString(array('max_length' => 10000, 'required' => false)),
      'cats_with_images'      => new sfValidatorString(array('max_length' => 10000, 'required' => false)),
      'recovery_secret'       => new sfValidatorString(array('max_length' => 10000, 'required' => false)),
      'is_active'             => new sfValidatorBoolean(array('required' => false)),
      'is_super_admin'        => new sfValidatorBoolean(array('required' => false)),
      'last_login'            => new sfValidatorDateTime(array('required' => false)),
      'created_at'            => new sfValidatorDateTime(),
      'updated_at'            => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'User', 'column' => array('username')))
    );

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

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

    $this->setupInheritance();

    parent::setup();
  }

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

}
