addFile() 공개 메소드

Adds a single file field.
public addFile ( string $name, string $class = null, string $classError = null ) : SpoonFormFile
$name string Name of the element.
$class string Class(es) that will be applied on the element.
$classError string Class(es) that will be applied on the element when an error occurs.
리턴 SpoonFormFile
예제 #1
0
 public function loadForm()
 {
     $this->form = new Form('settings');
     // we don't even have a auth config file yet, let the user upload it
     if ($this->get('fork.settings')->get($this->getModule(), 'certificate') === null) {
         $this->form->addFile('certificate');
         $this->form->addtext('email');
         return;
     }
     // we are authenticated! Let's see which account the user wants to use
     if ($this->get('fork.settings')->get($this->getModule(), 'account') === null) {
         $analytics = $this->get('analytics.google_analytics_service');
         try {
             $accounts = $analytics->management_accounts->listManagementAccounts();
         } catch (Google_Service_Exception $e) {
             $this->tpl->assign('email', $this->get('fork.settings')->get($this->getModule(), 'email'));
             return $this->tpl->assign('noAccounts', true);
         }
         $accountsForDropdown = array();
         foreach ($accounts->getItems() as $account) {
             $accountsForDropdown[$account->getId()] = $account->getName();
         }
         $this->form->addDropdown('account', $accountsForDropdown);
         return;
     }
     // we have an account, but don't know which property to track
     if ($this->get('fork.settings')->get($this->getModule(), 'web_property_id') === null) {
         $analytics = $this->get('analytics.google_analytics_service');
         $properties = $analytics->management_webproperties->listManagementWebproperties($this->get('fork.settings')->get($this->getModule(), 'account'));
         $propertiesForDropdown = array();
         foreach ($properties->getItems() as $property) {
             $propertiesForDropdown[$property->getId()] = $property->getName();
         }
         $this->form->addDropdown('web_property_id', $propertiesForDropdown);
         return;
     }
     // we have an account, but don't know which property to track
     if ($this->get('fork.settings')->get($this->getModule(), 'profile') === null) {
         $analytics = $this->get('analytics.google_analytics_service');
         $profiles = $analytics->management_profiles->listManagementProfiles($this->get('fork.settings')->get($this->getModule(), 'account'), $this->get('fork.settings')->get($this->getModule(), 'web_property_id'));
         $profilesForDropdown = array();
         foreach ($profiles->getItems() as $property) {
             $profilesForDropdown[$property->getId()] = $property->getName();
         }
         $this->form->addDropdown('profile', $profilesForDropdown);
         return;
     }
 }
 /**
  * Build up the form
  */
 private function build()
 {
     $this->form->addFile('certificate');
     $this->form->addText('email');
 }