本文整理汇总了PHP中Zend\Form\Element\File::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP File::setAttribute方法的具体用法?PHP File::setAttribute怎么用?PHP File::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\File
的用法示例。
在下文中一共展示了File::setAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addElements
public function addElements()
{
//-- File --
$file = new Element\File('file');
$file->setAttribute('placeholder', 'profile_name');
$file->setAttribute('required', 'true');
$file->setAttribute('class', 'form-control');
$file->setAttribute('id', 'file');
$file->setLabel('Profile name');
$file->setLabelAttributes(array('class' => 'control-label', 'for' => 'file'));
//-- Submit --
$submit = new Element\Submit('submit');
$submit->setAttribute('class', 'btn btn-success');
$submit->setValue('Send');
//-- Binding elements --
$this->add($file);
$this->add($submit);
}
示例2: addElements
public function addElements($multi)
{
$file = new Element\File('upload');
$file->setLabel('Bild hinzufügen:')->setAttribute('id', 'file');
if ($multi !== null) {
$file->setAttribute('multiple', true);
}
$this->add($file);
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Hochladen')));
}
示例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);
}
示例4: init
public function init()
{
$fileupload = new Element\File('files');
$fileupload->setLabel("files");
$fileupload->setAttribute('multiple', 'multiple');
$this->add($fileupload);
$button = new Element\Button('start');
$button->setAttribute("type", 'submit');
$button->setValue("Start upload")->setLabel("Start upload");
$this->add($button);
$button = new Element\Button('cancel');
$button->setAttribute("type", 'reset');
$button->setValue("Cancel upload")->setLabel("Cancel upload");
$this->add($button);
$button = new Element\Button('delete');
$button->setAttribute("type", 'button');
$button->setValue("Delete")->setLabel("Delete");
$this->add($button);
$checkbox = new Element\Checkbox('toggle');
$checkbox->setValue("Toggle")->setLabel("Toggle");
$checkbox->setAttribute("required", "");
$this->add($checkbox);
}
示例5: load
/**
* Load upload editor
*
* @return mixed
*/
public function load()
{
$parameters = $this->getConfig();
$property = $this->getProperty();
$upload = new Element\File($this->getName());
$value = $this->getValue();
$upload->setLabel($property->getName());
$upload->setAttribute('class', 'form-control')->setAttribute('id', $this->getName());
if (!empty($parameters['is_multiple'])) {
$upload->setAttribute('multiple', 'multiple');
$upload->setName($upload->getName());
}
$hiddenUpload = new Element\Hidden($this->getName() . '-hidden');
if (!empty($value)) {
$hiddenUpload->setValue($value);
}
return array($upload, $hiddenUpload, $this->addPath(__DIR__)->render('upload-editor.phtml', array('files' => $value, 'id' => $this->getName(), 'isMultiple' => $parameters['is_multiple'])));
}
示例6: testNameShouldHaveArrayNotationWhenMultipleIsSpecified
/**
* @return void
*/
public function testNameShouldHaveArrayNotationWhenMultipleIsSpecified()
{
$element = new Element\File('foo');
$element->setAttribute('multiple', true);
$markup = $this->helper->render($element);
$this->assertRegexp('#<input[^>]*?(name="foo\\[\\]")#', $markup);
}
示例7: generateFormElement
/**
*
* @param string $name
* @param string $type
* @param array $values
*/
protected function generateFormElement($name, $type, $values = array(), $priority = 100)
{
$options = $this->getOptions();
$option_elements = $options['form']['elements'];
switch (strtoupper($type)) {
case 'TEXT':
case 'CHAR':
case 'VARCHAR':
$elm = new Element($name);
$elm->setLabel(strtoupper($name));
$elm->setAttribute('id', $name . '_ID');
$elm->setAttributes(array('type' => 'text'));
break;
case 'ENUM':
$elm = new Element\Select($name);
$elm->setLabel(strtoupper($name));
$elm->setAttribute('id', $name . '_ID');
if ($values instanceof \Traversable) {
$elm->setValueOptions($values);
}
break;
case 'INT':
case 'INTEGER':
case 'NUMERIC(10, 0)':
case 'DECIMAL':
case 'NUMERIC':
case 'DOUBLE':
$elm = new Element($name);
$elm->setLabel(strtoupper($name));
$elm->setAttribute('id', $name . '_ID');
$elm->setAttributes(array('type' => 'number'));
break;
case 'DATE':
if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
$elm = new \Zf2datatable\Form\Element\DateCalendar($name);
$elm->setAttribute('id', $name . '_ID');
$elm->setAttribute('class', 'form-control');
$elm->setLabel($name);
$elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['date_js_properties']);
\Zf2datatable\Form\Element\DateCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['date_format_in']);
\Zf2datatable\Form\Element\DateCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['date_format_out']);
\Zf2datatable\Form\Element\DateCalendar::setDateFormatMaskIn($option_elements['DateTimePicker']['options']['date_format_mask_in']);
\Zf2datatable\Form\Element\DateCalendar::setDateFormatMaskOut($option_elements['DateTimePicker']['options']['date_format_mask_out']);
} else {
$elm = new Element\Date($name);
$elm->setLabel(strtoupper($name));
$elm->setAttributes(array('type' => 'date'));
$elm->setFormat('Y-m-d');
}
break;
case 'DATETIME':
if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
$elm = new \Zf2datatable\Form\Element\DateTimeCalendar($name);
$elm->setAttribute('id', $name . '_ID');
$elm->setAttribute('class', 'form-control');
$elm->setLabel($name);
$elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['datetime_js_properties']);
\Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['datetime_format_in']);
\Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['datetime_format_out']);
\Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatMaskIn($option_elements['DateTimePicker']['options']['datetime_format_mask_in']);
\Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatMaskOut($option_elements['DateTimePicker']['options']['datetime_format_mask_out']);
} else {
$elm = new Element\DateTimeSelect($name);
$elm->setLabel(strtoupper($name));
}
break;
case 'FILE':
$elm = new Element\File();
$elm->setLabel(strtoupper($name));
$elm->setAttribute('id', $name . '_ID');
break;
default:
$elm = new Element($name);
$elm->setLabel(strtoupper($name));
$elm->setAttribute('id', $name . '_ID');
$elm->setAttributes(array('type' => 'text'));
}
$elm->setOption('priority', $priority);
return $elm;
}