<?php

/**
 * Offer form base class.
 *
 * @method Offer 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 BaseOfferForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(array(), array()),
      'inner_id'             => new sfWidgetFormInputText(array(), array("size" => 65)),
      'quantity_type_select' => new sfWidgetFormChoice(array('choices' => array('m2' => 'm2', 'sheet' => 'sheet', 'piece' => 'piece')), array()),
      'price'                => new sfWidgetFormInputText(array(), array("size" => 8, "maxlength" => 8, "required" => true)),
      'product_id'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Product'), 'add_empty' => false), array("required" => true)),
      'img'                  => new sfWidgetFormInputText(array(), array("size" => 65)),
      'is_delete'            => new sfWidgetFormInputCheckbox(array(), array("required" => true)),
      'is_wholesale'         => new sfWidgetFormInputCheckbox(array(), array("required" => true)),
      'sort'                 => new sfWidgetFormInputText(array(), array("size" => 8, "maxlength" => 8)),
      '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)),
      'inner_id'             => new sfValidatorPass(array('required' => false)),
      'quantity_type_select' => new sfValidatorChoice(array('choices' => array(0 => 'm2', 1 => 'sheet', 2 => 'piece'), 'required' => false)),
      'price'                => new sfValidatorInteger(),
      'product_id'           => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Product'))),
      'img'                  => new sfValidatorPass(array('required' => false)),
      'is_delete'            => new sfValidatorBoolean(array('required' => false)),
      'is_wholesale'         => new sfValidatorBoolean(array('required' => false)),
      'sort'                 => new sfValidatorInteger(array('required' => false)),
      'created_at'           => new sfValidatorDateTime(),
      'updated_at'           => new sfValidatorDateTime(),
    ));

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

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

    $this->setupInheritance();

    parent::setup();
  }

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

}
