本文整理汇总了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);
}
示例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);
}
示例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);
}