本文整理匯總了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);
}