本文整理匯總了PHP中Zend\Form\Element::setAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Element::setAttributes方法的具體用法?PHP Element::setAttributes怎麽用?PHP Element::setAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Form\Element
的用法示例。
在下文中一共展示了Element::setAttributes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct($name = null)
{
parent::__construct('register');
// Creating Fields
$first_name = new Text('first_name');
$first_name->setAttributes(array('class' => 'form-control input-lg', 'placeholder' => 'Nome', 'tabindex' => '1'));
$last_name = new Text('last_name');
$last_name->setAttributes(array('class' => 'form-control input-lg', 'placeholder' => 'Sobrenome', 'tabindex' => '2'));
$email = new Text('email');
$email->setAttributes(array('class' => 'form-control input-lg', 'placeholder' => 'Email', 'tabindex' => '3'));
$password = new Password('password');
$password->setAttributes(array('class' => 'form-control input-lg', 'placeholder' => 'Senha', 'tabindex' => '4'));
$password_confirmation = new Password('password_confirmation');
$password_confirmation->setAttributes(array('class' => 'form-control input-lg', 'placeholder' => 'Senha', 'tabindex' => '5'));
$submit = new Element('submit');
$submit->setAttributes(array('class' => 'btn btn-success btn-block btn-lg', 'type' => 'submit', 'tabindex' => '7'))->setValue('Cadastrar');
// End Creating Fields
// Setting Fields
$this->add($first_name);
$this->add($last_name);
$this->add($email);
$this->add($password);
$this->add($password_confirmation);
$this->add($submit, array('priority' => -100));
}
示例2: __construct
public function __construct($name = null)
{
parent::__construct('datbaseform');
$this->setAttribute('class', 'p-t-15');
$this->setAttributes(array('id' => 'form-datos-bd', 'class' => 'form-horizontal'));
$username = new Element('username');
$username->setLabel('Nombre de Usuario:')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$username->setAttributes(array('type' => 'text', 'placeholder' => 'ej. Admin', 'id' => 'username', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno", 'data-rule-minlength' => "6", 'data-msg-minlength' => "Debe tener al menos 6 caracteres"));
$password = new Element\Password('password');
$password->setLabel('Contraseña:')->setLabelAttributes(array('class' => 'col-sm-3 control-label required'));
$password->setAttributes(array('placeholder' => 'No uses 1234 ;)', 'id' => 'password', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno"));
$confirmaPassword = new Element\Password('confirmaPassword');
$confirmaPassword->setLabel(' ')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$confirmaPassword->setAttributes(array('placeholder' => 'Por seguridad este campo es necesario', 'id' => 'confirmaPassword', 'class' => 'form-control'));
$email = new Element\Email('email');
$email->setLabel('Correo Electrónico:')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$email->setAttributes(array('placeholder' => 'admin@tudominio.com', 'id' => 'email', 'class' => 'form-control'));
$buttonContinuar = new Element\Button('buttonContinuar');
$buttonContinuar->setLabel('Instalar');
$buttonContinuar->setAttributes(array('class' => 'btn btn-success', 'type' => 'submit', 'id' => 'buttonContinuar'));
$buttonLimpiar = new Element\Button('buttonLimpiar');
$buttonLimpiar->setLabel('<i class="pg-close"></i> Limpiar')->setLabelOptions(array('disable_html_escape' => true));
$buttonLimpiar->setAttributes(array('class' => 'btn btn-default', 'id' => 'buttonLimpiar', 'type' => 'reset'));
$this->add($username);
$this->add($password);
$this->add($email);
$this->add($confirmaPassword);
$this->add($buttonContinuar);
$this->add($buttonLimpiar);
}
示例3: getCompleteElement
public function getCompleteElement()
{
$element = new Element('foo');
$element->setAttributes(array('accept' => 'value', 'accesskey' => 'value', 'alt' => 'value', 'autocomplete' => 'on', 'autofocus' => 'autofocus', 'checked' => 'checked', 'class' => 'value', 'contenteditable' => 'value', 'contextmenu' => 'value', 'dir' => 'value', 'dirname' => 'value', 'disabled' => 'disabled', 'draggable' => 'value', 'dropzone' => 'value', 'form' => 'value', 'formaction' => 'value', 'formenctype' => 'value', 'formmethod' => 'value', 'formnovalidate' => 'value', 'formtarget' => 'value', 'height' => 'value', 'hidden' => 'value', 'id' => 'value', 'lang' => 'value', 'list' => 'value', 'max' => 'value', 'maxlength' => 'value', 'min' => 'value', 'multiple' => 'multiple', 'name' => 'value', 'onabort' => 'value', 'onblur' => 'value', 'oncanplay' => 'value', 'oncanplaythrough' => 'value', 'onchange' => 'value', 'onclick' => 'value', 'oncontextmenu' => 'value', 'ondblclick' => 'value', 'ondrag' => 'value', 'ondragend' => 'value', 'ondragenter' => 'value', 'ondragleave' => 'value', 'ondragover' => 'value', 'ondragstart' => 'value', 'ondrop' => 'value', 'ondurationchange' => 'value', 'onemptied' => 'value', 'onended' => 'value', 'onerror' => 'value', 'onfocus' => 'value', 'oninput' => 'value', 'oninvalid' => 'value', 'onkeydown' => 'value', 'onkeypress' => 'value', 'onkeyup' => 'value', 'onload' => 'value', 'onloadeddata' => 'value', 'onloadedmetadata' => 'value', 'onloadstart' => 'value', 'onmousedown' => 'value', 'onmousemove' => 'value', 'onmouseout' => 'value', 'onmouseover' => 'value', 'onmouseup' => 'value', 'onmousewheel' => 'value', 'onpause' => 'value', 'onplay' => 'value', 'onplaying' => 'value', 'onprogress' => 'value', 'onratechange' => 'value', 'onreadystatechange' => 'value', 'onreset' => 'value', 'onscroll' => 'value', 'onseeked' => 'value', 'onseeking' => 'value', 'onselect' => 'value', 'onshow' => 'value', 'onstalled' => 'value', 'onsubmit' => 'value', 'onsuspend' => 'value', 'ontimeupdate' => 'value', 'onvolumechange' => 'value', 'onwaiting' => 'value', 'pattern' => 'value', 'placeholder' => 'value', 'readonly' => 'readonly', 'required' => 'required', 'size' => 'value', 'spellcheck' => 'value', 'src' => 'value', 'step' => 'value', 'style' => 'value', 'tabindex' => 'value', 'title' => 'value', 'width' => 'value', 'wrap' => 'value', 'xml:base' => 'value', 'xml:lang' => 'value', 'xml:space' => 'value', 'data-some-key' => 'value', 'option' => 'value', 'optgroup' => 'value', 'arbitrary' => 'value', 'meta' => 'value'));
$element->setValue('value');
return $element;
}
示例4: updateAction
public function updateAction()
{
$id = $this->params()->fromRoute('id');
if (!$id) {
return $this->redirect()->toRoute('album_dm/default', array('controller' => 'album-dm', 'action' => 'index'));
}
$entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
try {
$repository = $entityManager->getRepository('AlbumDm\\Entity\\Album');
$album = $repository->find($id);
} catch (\Exception $ex) {
echo $ex->getMessage();
// this never will be seen if you don't comment the redirect
return $this->redirect()->toRoute('album_dm/default', array('controller' => 'album-dm', 'action' => 'index'));
}
$builder = new DoctrineAnnotationBuilder($entityManager);
$form = $builder->createForm($album);
$form->setHydrator(new DoctrineHydrator($entityManager, 'AlbumDm\\Entity\\Album'));
$send = new Element('submit');
$send->setValue('Go');
// submit
$send->setAttributes(array('type' => 'submit'));
$form->add($send);
$form->bind($album);
$request = $this->getRequest();
if ($request->isPost()) {
$form->setData($request->getPost());
if ($form->isValid()) {
$entityManager->persist($album);
$entityManager->flush();
return $this->redirect()->toRoute('album_dm/default', array('controller' => 'album-dm', 'action' => 'index'));
}
}
return new ViewModel(array('form' => $form, 'id' => $id));
}
示例5: prepare
public function prepare()
{
$username = new Element('username');
$username->setLabel($this->translate('Your username'));
$username->setAttributes(['type' => 'text', 'icon' => 'user', 'class' => 'form-control']);
$email = new Element('email');
$email->setLabel($this->translate('Email (used to login)'));
$email->setAttributes(['type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
$password = new Element('password');
$password->setLabel($this->translate('Password'));
$password->setAttributes(['type' => 'password', 'id' => 'password', 'icon' => 'lock', 'class' => 'form-control']);
$confirmPassword = new Element('confirm-password');
$confirmPassword->setLabel($this->translate('Confirm Password'));
$confirmPassword->setAttributes(['type' => 'password', 'icon' => 'lock', 'class' => 'form-control']);
$send = new Element('send');
$send->setValue($this->translate('Create My Account'));
$send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
$this->add($username);
$this->add($email);
$this->add($password);
$this->add($confirmPassword);
$this->addCaptcha();
$this->add($send);
parent::prepare();
}
示例6: __construct
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function __construct($entityManager)
{
parent::__construct('contatoForm');
$this->setAttribute('method', 'post');
$this->setAttribute('id', 'fileupload');
$this->setEntityManager($entityManager);
$idContato = new Element('idContato');
$idContato->setLabel('Contato');
$idContato->setAttributes(array('name' => 'idContato', 'id' => 'idContato', 'type' => 'hidden'));
$this->add($idContato);
$email = new Element('email');
$email->setLabel('Email');
$email->setAttributes(array('name' => 'email', 'id' => 'email', 'type' => 'text', 'class' => 'form-control'));
$this->add($email);
$assunto = new Element('assunto');
$assunto->setLabel('Assunto');
$assunto->setAttributes(array('name' => 'assunto', 'id' => 'assunto', 'type' => 'text', 'class' => 'form-control'));
$this->add($assunto);
$mensagem = new Element\Textarea('mensagem');
$mensagem->setLabel('Mensagem');
$mensagem->setAttributes(array('name' => 'mensagem', 'id' => 'mensagem', 'type' => 'textarea', 'class' => 'form-control'));
$this->add($mensagem);
$submit = new Element('submit');
$submit->setValue('Salvar');
$submit->setAttributes(array('type' => 'submit'));
$this->add($submit);
}
示例7: __construct
public function __construct($name = null)
{
parent::__construct('objetosform');
$this->setAttribute('method', 'post');
$this->setAttribute('role', 'form');
$this->setAttributes(array('id' => 'objetosform'));
$objetos_actividad_id = new Element('objetos_actividad_id');
$objetos_actividad_id->setLabel('Actividad');
$objetos_actividad_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'objetos_actividad_id', 'readonly' => 'readonly', 'class' => 'form-control'));
$objetos_id = new Element('objetos_id');
$objetos_id->setLabel('ID');
$objetos_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'objetos_id', 'readonly' => 'readonly', 'class' => 'form-control'));
$objetos_nombre = new Element('objetos_nombre');
$objetos_nombre->setLabel('Nombre');
$objetos_nombre->setAttributes(array('type' => 'text', 'placeholder' => 'ej: wKER001', 'id' => 'objetos_nombre', 'class' => 'form-control'));
$objetos_tipo = new Element\Select('objetos_tipo');
$objetos_tipo->setLabel('Tipo');
$objetos_tipo->setEmptyOption('Elige un Tipo..');
$objetos_tipo->setOptions(array('disable_inarray_validator' => true));
$objetos_tipo->setAttributes(array('id' => 'objetos_tipo', 'class' => "form-control"));
$guardar = new Element\Button('guardar');
$guardar->setAttributes(array('class' => 'btn btn-success mr5', 'type' => 'submit', 'id' => 'guardar'));
$guardar->setOptions(array('label' => '<i class="glyphicon glyphicon-floppy-disk"></i>', 'label_options' => array('disable_html_escape' => true)));
$etiquetas_id = new Element\Hidden('etiquetas_id');
$etiquetas_id->setAttributes(array('id' => 'etiquetas_id'));
$this->add($objetos_actividad_id);
$this->add($objetos_id);
$this->add($objetos_nombre);
$this->add($objetos_tipo);
$this->add($etiquetas_id);
$this->add($guardar);
}
示例8: __construct
public function __construct($param = null)
{
$this->param = $param;
parent::__construct('register');
$first_name = new Element('first_name');
$first_name->setAttributes(array('type' => 'Zend\\Form\\Element\\Text', 'placeholder' => "Enter Your First Name", 'class' => "input-control", 'required' => true, 'id' => 'first_name'));
$last_name = new Element('last_name');
$last_name->setAttributes(array('type' => 'Zend\\Form\\Element\\Text', 'placeholder' => "Enter Your Last Name", 'class' => "input-control", 'required' => true, 'id' => 'last_name'));
$user_name = new Element('username');
$user_name->setAttributes(array('type' => 'Zend\\Form\\Element\\Text', 'placeholder' => "Enter Your Last Name", 'class' => "input-control", 'required' => true, 'id' => 'user_name'));
$email = new Element('email');
$email->setAttributes(array('type' => 'Zend\\Form\\Element\\Email', 'placeholder' => "Enter Your Email Address", 'class' => "input-control", 'required' => true, 'id' => 'email'));
$password = new Element('password');
$password->setAttributes(array('type' => 'password', 'placeholder' => "Create Your Password", 'class' => "input-control", 'required' => true, 'id' => 'password'));
$confirm_password = new Element('confirm_password');
$confirm_password->setAttributes(array('type' => 'password', 'placeholder' => "Re-enter Your Password", 'class' => "input-control", 'required' => true, 'id' => 'confirm_password'));
$submit_register = new Element('submit_register');
$submit_register->setAttributes(array('type' => 'Submit', 'value' => 'Sign Up', 'id' => 'submit_register'));
$this->setName("register");
$this->add($first_name);
$this->add($last_name);
$this->add($user_name);
$this->add($email);
$this->add($password);
$this->add($confirm_password);
$this->add($submit_register);
$this->setAttribute('enctype', 'multipart/form-data');
$rf = new RegisterFilter();
$this->inputFilter = $rf->getInputFilter();
$this->setInputFilter($this->inputFilter);
}
示例9: __construct
public function __construct($name = null)
{
parent::__construct('datbaseform');
$this->setAttribute('class', 'p-t-15');
$this->setAttributes(array('id' => 'form-datos-bd', 'class' => 'form-horizontal'));
$servidorBd = new Element('servidorBd');
$servidorBd->setLabel('Servidor de la base de datos:')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$servidorBd->setAttributes(array('type' => 'text', 'placeholder' => 'ej. localhost', 'id' => 'servidorBd', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno", 'data-rule-minlength' => "6", 'data-msg-minlength' => "Debe tener al menos 6 caracteres"));
$nombreBd = new Element('nombreBd');
$nombreBd->setLabel('Nombre de la base de datos:')->setLabelAttributes(array('class' => 'col-sm-3 control-label required'));
$nombreBd->setAttributes(array('type' => 'text', 'placeholder' => 'ej. tributum-produccion', 'id' => 'nombreBd', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno"));
$prefijoTablasBd = new Element('prefijoTablasBd');
$prefijoTablasBd->setLabel('Prefijo de tablas de la base de datos:')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$prefijoTablasBd->setAttributes(array('type' => 'text', 'placeholder' => 'ej. trb-', 'id' => 'prefijoTablasBd', 'class' => 'form-control'));
$nombreUsuarioBd = new Element('nombreUsuarioBd');
$nombreUsuarioBd->setLabel('Nombre de usuario de la base de datos:')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$nombreUsuarioBd->setAttributes(array('type' => 'text', 'placeholder' => 'ej. root', 'id' => 'nombreUsuarioBd', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno"));
$contrasenaDb = new Element\Password('contrasenaDb');
$contrasenaDb->setLabel('Contraseña de la base de datos:')->setLabelAttributes(array('class' => 'col-sm-3 control-label'));
$contrasenaDb->setAttributes(array('placeholder' => 'Por seguridad este campo es necesario', 'id' => 'contrasenaDb', 'class' => 'form-control'));
$buttonContinuar = new Element\Button('buttonContinuar');
$buttonContinuar->setLabel('Continuar');
$buttonContinuar->setAttributes(array('class' => 'btn btn-success', 'type' => 'submit', 'id' => 'buttonContinuar'));
$buttonLimpiar = new Element\Button('buttonLimpiar');
$buttonLimpiar->setLabel('<i class="pg-close"></i> Limpiar')->setLabelOptions(array('disable_html_escape' => true));
$buttonLimpiar->setAttributes(array('class' => 'btn btn-default', 'id' => 'buttonLimpiar', 'type' => 'reset'));
$this->add($servidorBd);
$this->add($nombreBd);
$this->add($prefijoTablasBd);
$this->add($nombreUsuarioBd);
$this->add($contrasenaDb);
$this->add($buttonContinuar);
$this->add($buttonLimpiar);
}
示例10: getCompleteElement
public function getCompleteElement()
{
$element = new Element('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' => 'multiple', 'name' => 'value', 'pattern' => 'value', 'placeholder' => 'value', 'readonly' => 'readonly', 'required' => 'required', 'size' => 'value', 'src' => 'value', 'step' => 'value', 'width' => 'value'));
$element->setValue('value');
return $element;
}
示例11: __construct
public function __construct($name = null)
{
parent::__construct('usuariosform');
$this->setAttribute('method', 'post');
$this->setAttribute('role', 'form');
$this->setAttributes(array('id' => 'usuariosform'));
$usuarios_id = new Element('usuarios_id');
$usuarios_id->setLabel('ID');
$usuarios_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'usuarios_id', 'readonly' => 'readonly', 'class' => 'form-control'));
$usuarios_username = new Element('usuarios_username');
$usuarios_username->setLabel('Usuario');
$usuarios_username->setAttributes(array('type' => 'text', 'placeholder' => 'dvader', 'id' => 'usuarios_username', 'class' => 'form-control'));
$usuarios_nombres = new Element('usuarios_nombres');
$usuarios_nombres->setLabel('Nombre');
$usuarios_nombres->setAttributes(array('type' => 'text', 'placeholder' => 'Darth Vader', 'id' => 'usuarios_nombres', 'class' => 'form-control'));
$usuarios_estado = new Element\Select('usuarios_estado');
$usuarios_estado->setLabel('Estado');
//$usuarios_estado->setEmptyOption('ELige un Estado..');
$usuarios_estado->setOptions(array('disable_inarray_validator' => true));
$usuarios_estado->setAttributes(array('id' => 'usuarios_estado', 'class' => "form-control", 'data-rule-required' => "true", 'data-msg-required' => "Debe seleccionar el Estado"));
$guardar = new Element\Button('guardar');
$guardar->setAttributes(array('class' => 'btn btn-success mr5', 'type' => 'submit', 'id' => 'guardar'));
$guardar->setOptions(array('label' => '<i class="glyphicon glyphicon-floppy-disk"></i>', 'label_options' => array('disable_html_escape' => true)));
$this->add($usuarios_id);
$this->add($usuarios_username);
$this->add($usuarios_nombres);
$this->add($usuarios_estado);
$this->add($guardar);
}
示例12: testCanClearAllAttributes
public function testCanClearAllAttributes()
{
$element = new Element();
$attributes = array('type' => 'text', 'class' => 'text-element', 'data-foo' => 'bar');
$element->setAttributes($attributes);
$element->clearAttributes();
$this->assertEquals(array(), $element->getAttributes());
}
示例13: createElement
protected function createElement(Element $element, $attr = array())
{
$tmpAttr = $element->getAttributes();
$element->setAttributes($this->_getElementAttr($element, $attr));
$html = $this->_getElementRenderer($element->getAttribute('type'))->render($element);
$element->setAttributes($tmpAttr);
return $html;
}
示例14: createElement
public function createElement(Element $form, $attr = array())
{
$tmpAttr = $form->getAttributes();
$form->setAttributes($this->_getElementAttr($form, $attr));
$html = $this->view->form()->openTag($form);
$form->setAttributes($tmpAttr);
return $html;
}
示例15: testSpecifiedAttributesOverrideDefaults
public function testSpecifiedAttributesOverrideDefaults()
{
$messages = $this->getMessageList();
$element = new Element('foo');
$element->setMessages($messages);
$element->setAttributes(array('class' => 'foo'));
$markup = $this->helper->render($element, array('class' => 'error'));
$this->assertContains('ul class="error"', $markup);
}