示例#1
0
 public function testForm()
 {
     $fileName = tempnam(sys_get_temp_dir(), 'test');
     copy(APPLICATION_PATH . '/../library/Centurion/Contrib/media/tests/Support/images/centurion.png', $fileName);
     //We create empty data.
     $_FILES['filename_'] = array('name' => 'centurion.png', 'type' => 'image/png', 'tmp_name' => $fileName, 'error' => 4, 'size' => 676);
     $form = new Media_Form_Model_Admin_File();
     $result = $form->getFilename()->isValid(array());
     $this->assertTrue($result);
     $result = $form->isValid(array());
     $this->assertTrue($result);
 }
示例#2
0
 public function init()
 {
     parent::init();
     $this->setLegend($this->_translate('Edit flatpage'));
     $this->getElement('body')->setAttrib('class', 'field-rte')->setAttrib('large', true)->removeFilter('StripTags');
     $this->getElement('flatpage_template_id')->setAttrib('large', true);
     //$this->getElement('mptt_parent_id')->setAttrib('large', true);
     $this->getElement('published_at')->setAttrib('large', true);
     $this->getElement('published_at')->setRequired(false)->setAttrib('class', 'field-datetimepicker');
     $this->getElement('url')->addValidator(new Centurion_Form_Model_Validator_AlreadyTaken('cms/flatpage', 'url'));
     $this->addElement('info', 'created_at', array('label' => 'Created at'));
     $this->addElement('info', 'updated_at', array('label' => 'Updated at'));
     $pic = new Media_Form_Model_Admin_File(array('name' => 'cover'));
     $pic->getFilename()->getValidator('Size')->setMax(4 * 1024 * 1024);
     $this->addReferenceSubForm($pic, 'cover');
 }
示例#3
0
 public function getValues($suppressArrayNotation = false)
 {
     if ($this->_validated) {
         if (null !== $this->_values) {
             return $this->_values;
         }
         return parent::getValues($suppressArrayNotation);
     }
 }
示例#4
0
 public function init()
 {
     parent::init();
     $this->filename->setIsArray(true)->setAttrib('class', 'multi')->addValidator('Count', false, array('min' => 1, 'max' => 3));
 }