當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::prepareElement方法代碼示例

本文整理匯總了PHP中Zend\Form\Element\File::prepareElement方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::prepareElement方法的具體用法?PHP File::prepareElement怎麽用?PHP File::prepareElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\Element\File的用法示例。


在下文中一共展示了File::prepareElement方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepareElement

 public function prepareElement(FormInterface $form)
 {
     $form->setAttribute('class', ($this->isMultiple() ? 'multi' : 'single') . '-file-upload');
     $form->setAttribute('data-is-empty', null === $this->getValue());
     $this->form = $form;
     parent::prepareElement($form);
 }
開發者ID:bitrecruiter,項目名稱:CrossApplicantManager,代碼行數:7,代碼來源:FileUpload.php

示例2: testWillAddFileEnctypeAttributeToForm

 public function testWillAddFileEnctypeAttributeToForm()
 {
     $file = new FileElement('foo');
     $formMock = $this->getMock('Zend\\Form\\Form');
     $formMock->expects($this->exactly(1))->method('setAttribute')->with($this->stringContains('enctype'), $this->stringContains('multipart/form-data'));
     $file->prepareElement($formMock);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:7,代碼來源:FileTest.php

示例3: __construct

 public function __construct(array $profileOptions, array $config)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     foreach ($profileOptions as $profileOption) {
         switch ($profileOption['inputType']) {
             case ProfileOptionForm::INPUT_TYPE_TEXTAREA:
                 $element = new Textarea($profileOption['name']);
                 break;
             case ProfileOptionForm::INPUT_TYPE_TEXT:
                 $element = new Text($profileOption['name']);
                 break;
             case ProfileOptionForm::INPUT_TYPE_DATE:
                 $element = new Text($profileOption['name']);
                 break;
             case ProfileOptionForm::INPUT_TYPE_TIME:
                 $element = new Text($profileOption['name']);
                 break;
             case ProfileOptionForm::INPUT_TYPE_DATETIME:
                 $element = new Text($profileOption['name']);
                 break;
             case ProfileOptionForm::INPUT_TYPE_PICTURE_UPLOAD:
                 $element = new File($profileOption['name']);
                 $element->prepareElement($this);
                 if (array_key_exists($profileOption['name'], $config['upload_target'])) {
                     $uploadTarget = $config['upload_target'][$profileOption['name']];
                 } else {
                     $uploadTarget = $config['upload_target']['default'];
                 }
                 $this->inputFilterSpec[] = ['type' => FileInput::class, 'name' => $profileOption['name'], 'required' => false, 'filters' => [['name' => 'filerenameupload', 'options' => ['target' => $uploadTarget, 'randomize' => true, 'use_upload_extension' => true]]], 'validators' => [['name' => 'fileisimage']]];
                 break;
             default:
                 break 2;
         }
         $element->setLabel($profileOption['name']);
         $element->setAttribute('class', 'form-control');
         $this->add($element);
     }
     $submit = new Submit('save');
     $submit->setValue('save');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
開發者ID:zend-bricks,項目名稱:bricks-user,代碼行數:43,代碼來源:ProfileForm.php


注:本文中的Zend\Form\Element\File::prepareElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。