本文整理汇总了PHP中Zend\Form\Element\File::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP File::setAttributes方法的具体用法?PHP File::setAttributes怎么用?PHP File::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\File
的用法示例。
在下文中一共展示了File::setAttributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCompleteElement
/**
* @return Element\File
*/
public function getCompleteElement()
{
$element = new Element\File('foo');
$element->setAttributes(array('accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', 'autofocus' => 'autofocus', 'checked' => 'checked', 'dirname' => 'value', 'disabled' => 'disabled', 'form' => 'value', 'formaction' => 'value', 'formenctype' => 'value', 'formmethod' => 'value', 'formnovalidate' => 'value', 'formtarget' => 'value', 'height' => 'value', 'id' => 'value', 'list' => 'value', 'max' => 'value', 'maxlength' => 'value', 'min' => 'value', 'multiple' => false, 'name' => 'value', 'pattern' => 'value', 'placeholder' => 'value', 'readonly' => 'readonly', 'required' => 'required', 'size' => 'value', 'src' => 'value', 'step' => 'value', 'width' => 'value'));
$element->setValue('value');
return $element;
}
示例2: __construct
public function __construct(EntityManager $objectManager)
{
parent::__construct('ligue');
$this->setAttributes(array('method' => 'post', 'id' => 'auth', 'role' => 'form'));
$this->setInputFilter(new LigueFilter($objectManager));
$this->setHydrator(new DoctrineObject($objectManager));
// Id
$id = new Hidden('id');
$this->add($id);
// Nom
$nom = new Text('nom');
$nom->setLabel('Nom')->setLabelAttributes(array('class', 'control-label'));
$nom->setAttributes(array('id' => 'nom', 'class' => 'form-control', 'placeholder' => 'Nom', 'required' => true));
$this->add($nom);
// Image
$image = new File('image');
$image->setLabel('Image')->setLabelAttributes(array('class', 'control-label'));
$image->setAttributes(array('id' => 'image', 'class' => 'form-control', 'placeholder' => 'Image'));
$this->add($image);
// Date début
$dateDebut = new Text('dateDebut');
$dateDebut->setLabel('Début de la ligue')->setLabelAttributes(array('class', 'control-label'));
$dateDebut->setAttributes(array('id' => 'dateDebut', 'class' => 'form-control'));
//$this->add($dateDebut);
// Date fin
$dateFin = new Text('dateFin');
$dateFin->setLabel('Fin de la ligue')->setLabelAttributes(array('class', 'control-label'));
$dateFin->setAttributes(array('id' => 'dateFin', 'class' => 'form-control'));
//$this->add($dateFin);
// Submit
$submit = new Submit('submit');
$submit->setValue('Enregistrer');
$submit->setAttributes(array('class' => 'btn btn-primary'));
$this->add($submit);
}
示例3: form
/**
* {@inheritDoc}
*/
public function form(PhpRenderer $view, array $options = [])
{
$fileInput = new File('file[__index__]');
$fileInput->setOptions(['label' => $view->translate('Upload File')]);
$fileInput->setAttributes(['id' => 'media-file-input-__index__']);
$field = $view->formRow($fileInput);
return $field . '<input type="hidden" name="o:media[__index__][file_index]" value="__index__">';
}
示例4: __construct
public function __construct($name = null)
{
parent::__construct('filmes');
$this->setAttribute('enctype', 'multipart/form-data');
$id = new Hidden('filmes_id');
$nome = new Text('filmes_nome');
$nome->setLabel('Nome: ');
$nome->setAttributes(array('class' => 'form-control', 'id' => 'filmes_nome'));
$preco = new Text('filmes_preco');
$preco->setLabel('Valor Aluguel: ');
$preco->setAttributes(array('class' => 'form-control', 'id' => 'filmes_preco'));
$categoria = new Select('categoria_id');
$categoria->setLabel('Categoria: ');
$categoria->setAttributes(array('class' => 'form-control', 'id' => 'categoria_id', 'empty_option' => 'Please select an author', 'value_options' => $this->getOptionsForSelect()));
$foto = new File('filmes_foto');
$foto->setLabel('Cartaz: ');
$foto->setAttributes(array('class' => 'form-control'));
$descricao = new Textarea('filmes_descricao');
$descricao->setLabel('Dados do Filme: ');
$descricao->setAttributes(array('style' => 'height: 100px;', 'class' => 'form-control', 'id' => 'filmes_descricao'));
$status = new Checkbox('filmes_status');
$status->setLabel("Mostrar?");
$status->setValue(1);
$submit = new Button('submit');
$submit->setLabel('Cadastrar');
$submit->setAttributes(array('type' => 'submit', 'class' => 'btn btn-success'));
$cancel = new Button('cancel');
$cancel->setLabel('Cancelar');
$cancel->setAttributes(array('type' => 'button', 'class' => 'btn btn-default', 'onclick' => 'javascript:history.go(-1)'));
$this->add($id);
$this->add($nome);
$this->add($preco);
$this->add($foto);
$this->add($descricao);
$this->add($categoria);
$this->add($status);
$this->add($submit);
$this->add($cancel);
}
示例5: render
public function render($formPV, $id)
{
$form = new Form();
$form->setAttribute('id', $id);
$inputFilter = new \Zend\InputFilter\InputFilter();
$factory = new InputFactory();
foreach ($formPV as $element) {
if (isset($element->line_text)) {
$attributes = $element->line_text[0];
$name = isset($attributes->name) ? $attributes->name : '';
$type = isset($attributes->type) ? $attributes->type : '';
$position = isset($attributes->order) ? $attributes->order : '';
$placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
$label = isset($attributes->data->label) ? $attributes->data->label : '';
//$required = ($attributes->data->required == 'true') ? true : false ;
$required = false;
$class = isset($attributes->data->class) ? $attributes->data->class : '';
$id = isset($attributes->data->id) ? $attributes->data->id : '';
$lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
$lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
$element = new Element\Text($name);
$element->setName($label);
$element->setLabel($label);
$element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
$form->add($element);
$options = array();
$options['encoding'] = 'UTF-8';
if ($lengthMin && $lengthMin > 0) {
$options['min'] = $lengthMin;
}
if ($lengthMax && $lengthMax > $lengthMin) {
$options['max'] = $lengthMax;
$element->setAttribute('maxlength', $lengthMax);
$options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax));
}
$inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
}
if (isset($element->line_email)) {
$attributes = $element->line_email[0];
$name = isset($attributes->name) ? $attributes->name : '';
$type = isset($attributes->type) ? $attributes->type : '';
$position = isset($attributes->order) ? $attributes->order : '';
$placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
$label = isset($attributes->data->label) ? $attributes->data->label : '';
//$required = ($attributes->data->required == 'true') ? true : false ;
$required = false;
$class = isset($attributes->data->class) ? $attributes->data->class : '';
$id = isset($attributes->data->id) ? $attributes->data->id : '';
$lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
$lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
$element = new Element\Email($name);
$element->setLabel($label);
$element->setName($label);
$element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
$form->add($element);
$options = array();
$options['encoding'] = 'UTF-8';
if ($lengthMin && $lengthMin > 0) {
$options['min'] = $lengthMin;
}
if ($lengthMax && $lengthMax > $lengthMin) {
$options['max'] = $lengthMax;
$element->setAttribute('maxlength', $lengthMax);
$options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax));
}
$inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
}
if (isset($element->line_checkbox)) {
$attributes = $element->line_checkbox[0];
$name = isset($attributes->name) ? $attributes->name : '';
$type = isset($attributes->type) ? $attributes->type : '';
$position = isset($attributes->order) ? $attributes->order : '';
$label = isset($attributes->data->label) ? $attributes->data->label : '';
// $required = ($attributes->data->required == 'yes') ? true : false;
$required = false;
$class = isset($attributes->data->class) ? $attributes->data->class : '';
$id = isset($attributes->data->id) ? $attributes->data->id : '';
$lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
$lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
$innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array();
$element = new Element\MultiCheckbox($name);
$element->setLabel($label);
$element->setName($label);
$element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
$values = array();
foreach ($innerData as $value) {
$values[] = $value->label;
}
$element->setValueOptions($values);
$form->add($element);
$options = array();
$options['encoding'] = 'UTF-8';
$inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required)));
}
if (isset($element->line_paragraph)) {
$attributes = $element->line_paragraph[0];
$name = isset($attributes->name) ? $attributes->name : '';
$type = isset($attributes->type) ? $attributes->type : '';
$position = isset($attributes->order) ? $attributes->order : '';
$placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
//.........这里部分代码省略.........