* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ */ class BulletinForm extends BaseBulletinForm { public function configure() { unset($this['created_at']); unset($this['updated_at']); unset($this['send_date']); unset($this['subscribers_num']); $this->widgetSchema['content'] = saWidgetFormCKEditorFactory::getWidget(); if($this->isNew() || !$this->getObject()->hasFile()) { $this->widgetSchema['filename'] = new sfWidgetFormInputFile(); } else { $this->widgetSchema['filename'] = new sfWidgetFormInputFileEditable(array( 'file_src' => $this->getObject()->getSrc(), 'delete_label' => __('odstranit aktuální soubor'), )); $this->validatorSchema['filename_delete'] = new sfValidatorBoolean(array('required' => false)); } $this->validatorSchema['filename'] = new sfValidatorFile(array( 'required' => false, 'path' => Bulletin::getCommonPath(), // 'mime_type_guessers' => array('guessFromFileBinary'), )); $culture = 'cs'; $this->widgetSchema['planned_date'] = new sfWidgetFormJQueryDate(array('culture' => $culture, 'date_widget' => new sfWidgetFormI18nDate(array('culture' => $culture,'can_be_empty' => true, 'format' => '%day%.%month%.%year%')))); $this->widgetSchema->setLabels(array( 'filename' => __('Pdf'), 'subject' => __('Předmět'), 'is_planned' => __('Naplánovat rozeslání'), 'planned_date' => __('Datum rozeslání'), 'note' => __('Poznámka'), )); commonFormFunctions::setJqUiFormater($this); commonFormFunctions::addClasses($this); } /** * Removes the current file for the field. * * @param string $field The field name */ protected function removeFile($field) { if($field == 'filename') { $this->getObject()->deleteFiles(); return; } parent::removeFile($field); } public function getJavaScripts() { $js = parent::getJavaScripts(); $js[] = 'forms/BulletinForm.js'; return $js; } }