当前位置: 首页>>代码示例>>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;未经允许,请勿转载。