示例#1
0
 public function configure()
 {
     unset($this['number'], $this['created_at'], $this['updated_at']);
     // we unset paid_amount so the system don't "nullify" the field on every invoice editing.
     unset($this['paid_amount']);
     $this->number = $this->getObject()->getNumber();
     $this->widgetSchema['issue_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['due_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['draft'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['closed']->setLabel('Force to be closed');
     $this->widgetSchema['sent_by_email']->setLabel('Sent by email');
     $this->setDefaults(array('issue_date' => time(), 'draft' => 0));
     $this->widgetSchema->setNameFormat('invoice[%s]');
     parent::configure();
 }
 public function configure()
 {
     unset($this['created_at'], $this['updated_at'], $this['occurrences'], $this['last_execution_date'], $this['desync'], $this['closed']);
     $this->widgetSchema['starting_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['finishing_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['period'] = new sfWidgetFormInputText(array(), array('size' => 3));
     $this->widgetSchema['period_type'] = new sfWidgetFormSelect(array('choices' => RecurringInvoiceTable::$period_types));
     $this->widgetSchema['max_occurrences'] = new sfWidgetFormInputText(array(), array('size' => 3));
     $this->widgetSchema['days_to_due'] = new sfWidgetFormInputText(array(), array('size' => 3));
     $this->widgetSchema['year'] = new sfWidgetFormI18nDateDMY(array('use' => 'years', 'culture' => $this->culture, 'empty_value' => 'any'));
     $this->widgetSchema['month'] = new sfWidgetFormI18nDateDMY(array('use' => 'months', 'culture' => $this->culture, 'empty_value' => 'any'));
     $this->widgetSchema->setDefault('enabled', '0');
     $this->widgetSchema->setNameFormat("invoice[%s]");
     $this->validatorSchema['starting_date'] = new sfValidatorDate(array('required' => true));
     $this->validatorSchema['period']->setMessage('invalid', 'Invalid Period');
     $this->validatorSchema['period']->setMessage('required', 'Period required');
     $this->setValidator('period_type', new sfValidatorChoice(array('choices' => array_keys(RecurringInvoiceTable::$period_types))));
     $vd = new sfValidatorSchema(array('period_type' => $this->getValidator('period_type'), 'period' => $this->getValidator('period')));
     $this->validatorSchema->setPostValidator(new SiwappConditionalValidator(array('control_field' => 'enabled', 'validator_schema' => $vd)));
     $this->widgetSchema->setLabels(array('max_occurrences' => 'Maximum number of occurrences', 'period' => 'Create every', 'period_type' => ' '));
     parent::configure();
 }