* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ */ class PrepayProfileForm extends ProfileForm { public function configure() { parent::configure(); unset($this['agree']); unset($this['user_id']); unset($this['mail']); unset($this['tel']); unset($this['web']); unset($this['name']); unset($this['region_id']); unset($this['city']); unset($this['street']); unset($this['zip']); unset($this['first_name']); unset($this['text']); unset($this['last_name']); unset($this['prefix']); unset($this['sufix']); unset($this['type_id']); unset($this['filename']); unset($this['is_public']); unset($this['ic']); unset($this['bank_account']); unset($this['representant_id']); unset($this['is_pdf_subscriber']); unset($this['logo_no_resize']); $this->widgetSchema['country_id'] = new sfWidgetFormInputHidden(); if($this->getOption('backend') == true) { $this->widgetSchema['prepayment_active'] = new sfWidgetFormInputCheckbox(); } else { $this->widgetSchema['prepayment_active'] = new sfWidgetFormInputHidden(); } $this->widgetSchema['prepayment_active']->setLabel(__('Aktivní')); $this->validatorSchema['prepayment_active'] = new sfValidatorBoolean(array('required' => false)); $this->widgetSchema['prepayment_type_id'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PrepaymentType'), 'add_empty' => false)); $this->widgetSchema['prepayment_type_id']->setLabel('Typ'); foreach(Doctrine::getTable('JobStyle')->findAll() as $style) { $this->widgetSchema['prepayment_count_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_count_'.$style->getId()]->setLabel($style->getName()); $this->setDefault('prepayment_count_'.$style->getId(), $this->getObject()->getPrepaymentCount($style)); $this->widgetSchema['prepayment_discount_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_discount_'.$style->getId()]->setLabel($style->getName()); $this->validatorSchema['prepayment_discount_'.$style->getId()] = new sfValidatorNumber(); $this->setDefault('prepayment_discount_'.$style->getId(), $this->getObject()->getPrepaymentDiscountAsPercent($style)); $this->widgetSchema['prepayment_request_count_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_request_count_'.$style->getId()]->setLabel($style->getName()); $this->validatorSchema['prepayment_request_count_'.$style->getId()] = new sfValidatorNumber(); $this->setDefault('prepayment_request_count_'.$style->getId(), $this->getObject()->getPrepaymentRequestCount($style)); $this->widgetSchema['prepayment_request_discount_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_request_discount_'.$style->getId()]->setLabel($style->getName()); $this->validatorSchema['prepayment_request_discount_'.$style->getId()] = new sfValidatorNumber(); $this->setDefault('prepayment_request_discount_'.$style->getId(), $this->getObject()->getPrepaymentRequestDiscountAsPercent($style)); $this->widgetSchema['prepayment_rows_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_rows_'.$style->getId()]->setLabel($style->getName()); $this->validatorSchema['prepayment_rows_'.$style->getId()] = new sfValidatorInteger(array('required' => false)); $this->setDefault('prepayment_rows_'.$style->getId(), $this->getObject()->getPrepaymentRows($style)); $this->widgetSchema['prepayment_rows_discount_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_rows_discount_'.$style->getId()]->setLabel($style->getName()); $this->validatorSchema['prepayment_rows_discount_'.$style->getId()] = new sfValidatorNumber(); $this->setDefault('prepayment_rows_discount_'.$style->getId(), $this->getObject()->getPrepaymentRowsDiscountAsPercent($style)); $this->widgetSchema['prepayment_request_rows_'.$style->getId()] = new sfWidgetFormInputText(); $this->widgetSchema['prepayment_request_rows_'.$style->getId()]->setLabel($style->getName()); $this->validatorSchema['prepayment_request_rows_'.$style->getId()] = new sfValidatorNumber(); $this->setDefault('prepayment_request_rows_'.$style->getId(), $this->getObject()->getPrepaymentRequestRows($style)); } $this->validatorSchema->setPostValidator( new sfValidatorCallback(array('callback' => array($this, 'checkDates'))) ); commonFormFunctions::setJqUiFormater($this); commonFormFunctions::addClasses($this); } public function checkDates($validator, $values) { if(isset($values['prepayment_from']) && isset($values['prepayment_to'])) { if(strlen($values['prepayment_from']) > 0 && strlen($values['prepayment_to']) > 0 && strtotime($values['prepayment_from']) >= strtotime($values['prepayment_to'])) { throw new sfValidatorError($validator, __('Datum "Od" musí být před datem "Do".')); } } return $values; } public function bind(array $taintedValues = null, array $taintedFiles = null) { parent::bind($taintedValues, $taintedFiles); } }