ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/form/opPluginChannelReleaseForm.class.php @ 9438

Last change on this file since 9438 was 9438, checked in by ebihara, 12 years ago

#3030:added some methods for opPluginChannelPackage* models and forms

File size: 1.4 KB
Line 
1<?php
2
3/**
4 * opPluginChannelRelease form.
5 *
6 * @package    OpenPNE
7 * @subpackage form
8 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
9 */
10class opPluginChannelReleaseForm extends BaseopPluginChannelReleaseForm
11{
12  public function configure()
13  {
14    $this->widgetSchema['package_id'] = new sfWidgetFormInputHidden();
15    $this->widgetSchema['manager_id'] = new sfWidgetFormInputHidden();
16    $this->widgetSchema['created_at'] = new sfWidgetFormInputHidden();
17    $this->widgetSchema['updated_at'] = new sfWidgetFormInputHidden();
18
19    $this->widgetSchema['stability'] = new sfWidgetFormSelect(array('choices' => opPluginChannelRelease::$stabilityList));
20
21    $this->widgetSchema['file'] = new sfWidgetFormInputFile();
22    $validatorFileOptions = array();
23    if (!$this->isNew())
24    {
25      $validatorFileOptions['required'] = false;
26    }
27    $this->validatorSchema['file'] = new sfValidatorFile($validatorFileOptions);
28
29    unset($this['file_id']);
30
31    $this->setDefaults($this->getOption('defaults'));
32  }
33
34  public function updateObject()
35  {
36    $object = parent::updateObject();
37
38    $input = $this->getValue('file');
39    if (!$input)
40    {
41      return $object;
42    }
43
44    $file = new File();
45    $file->setName(time());
46    $file->setOriginalFilename($input->getOriginalName());
47    $file->setBin(file_get_contents($input->getTempName()));
48    $file->setType($input->getType());
49
50    $object->setFile($file);
51
52    return $object;
53  }
54}
Note: See TracBrowser for help on using the repository browser.