Esempio n. 1
0
 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);
 }
 /**
  * @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);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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' => '*****@*****.**', '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);
 }
Esempio n. 6
0
 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();
 }
Esempio n. 7
0
 public function testCanRenderRowLabelAttributes()
 {
     $element = new Element('foo');
     $element->setLabel('The value for foo:');
     $element->setLabelAttributes(array('class' => 'bar'));
     $this->helper->setLabelPosition('append');
     $markup = $this->helper->render($element);
     $this->assertContains("<label class=\"bar\">", $markup);
 }
 public function prepare()
 {
     $email = new Element('passwordreset-email');
     $email->setLabel($this->translate('Email'));
     $email->setAttributes(['id' => 'passwordreset-email', 'type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $this->add($email);
     $send = new Element('send');
     $send->setValue('Request password reset');
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($send);
     parent::prepare();
 }
Esempio n. 9
0
 public function __construct($name = null, $options = array())
 {
     parent::__construct("page", $options);
     $this->setAttribute("method", "post");
     $this->setAttribute("id", "pageform");
     $this->add(array("name" => "id", "attributes" => array("type" => "hidden", "value" => "0")));
     $this->add(array("name" => "article", "attributes" => array("type" => "textarea"), "options" => array("label" => "Description")));
     $title = new Element("title");
     $title->setAttribute("type", "text");
     $title->setLabel("Title");
     $this->add($title);
     $this->add(array("name" => "date", "attributes" => array("type" => "text"), "options" => array("label" => "Publication Date")));
     $this->add(array("name" => "submit", "type" => "submit", "attributes" => array("value" => "Отправить", "id" => "submitbutton", "class" => "btn")));
 }
Esempio n. 10
0
 public function __construct($name = null)
 {
     parent::__construct('actividadesform');
     $this->setAttribute('method', 'post');
     $this->setAttribute('role', 'form');
     $this->setAttributes(array('id' => 'actividadesform'));
     $actividades_id = new Element('actividades_id');
     $actividades_id->setLabel('ID');
     $actividades_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'actividades_id', 'readonly' => 'readonly', 'class' => 'form-control'));
     $actividades_nombre = new Element('actividades_nombre');
     $actividades_nombre->setLabel('Nombre');
     $actividades_nombre->setAttributes(array('type' => 'text', 'placeholder' => 'ej: Mi Primera Actividad', 'id' => 'actividades_nombre', 'class' => 'form-control'));
     $actividades_estado = new Element\Select('actividades_estado');
     $actividades_estado->setLabel('Estado');
     //$actividades_estado->setEmptyOption('ELige un Estado..');
     $actividades_estado->setOptions(array('disable_inarray_validator' => true));
     $actividades_estado->setAttributes(array('id' => 'actividades_estado', 'class' => "form-control", 'data-rule-required' => "true", 'data-msg-required' => "Debe seleccionar el Estado"));
     $actividades_responsable = new Element\Select('actividades_responsable');
     $actividades_responsable->setLabel('Responsable');
     // $actividades_responsable->setEmptyOption('Elige un Responsable..');
     $actividades_responsable->setOptions(array('disable_inarray_validator' => true));
     $actividades_responsable->setAttributes(array('id' => 'actividades_responsable', 'class' => "form-control"));
     $actividades_area = new Element\Select('actividades_area');
     $actividades_area->setLabel('Área');
     $actividades_area->setEmptyOption('Elige una Área..');
     $actividades_area->setOptions(array('disable_inarray_validator' => true));
     $actividades_area->setAttributes(array('id' => 'actividades_area', 'class' => "form-control"));
     $actividades_reporta = new Element('actividades_reporta');
     $actividades_reporta->setLabel('Reportada Por');
     $actividades_reporta->setAttributes(array('type' => 'text', 'placeholder' => 'Persona que reporta', 'id' => 'actividades_reporta', 'class' => 'form-control'));
     $actividades_fecha = new Element('actividades_fecha');
     $actividades_fecha->setLabel('Fecha de Inicio');
     $actividades_fecha->setAttributes(array('placeholder' => 'Fecha de Inicio', 'id' => 'actividades_fecha', 'class' => 'form-control'));
     $actividades_fecha_fin = new Element('actividades_fecha_fin');
     $actividades_fecha_fin->setLabel('Fecha de Finalización');
     $actividades_fecha_fin->setAttributes(array('placeholder' => 'Fecha de Finalización', 'id' => 'actividades_fecha_fin', '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)));
     $this->add($actividades_id);
     $this->add($actividades_nombre);
     $this->add($actividades_fecha);
     $this->add($actividades_estado);
     $this->add($actividades_responsable);
     $this->add($actividades_area);
     $this->add($actividades_reporta);
     $this->add($actividades_fecha_fin);
     $this->add($guardar);
 }
 public function prepare()
 {
     $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('Update password'));
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-success']);
     $this->add($password);
     $this->add($confirmPassword);
     $this->add($send);
     parent::prepare();
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function __construct($entityManager)
 {
     parent::__construct('contatoSearchForm');
     $this->setAttribute('method', 'post');
     $this->setAttribute('id', 'contatoSearch');
     $this->setAttribute('class', 'form-inline');
     $this->setEntityManager($entityManager);
     $nome = new Element('likeField');
     $nome->setAttributes(array('name' => 'likeField', 'id' => 'likeField', 'type' => 'text', 'data-ng-model' => 'list.search'));
     $nome->setLabel('Palavra Chave ');
     $this->add($nome);
     $submit = new Element('clear');
     $submit->setValue('Limpar');
     $submit->setAttributes(array('type' => 'button', 'data-ng-click' => 'list.clearSearch()'));
     $this->add($submit);
 }
Esempio n. 13
0
 public function prepare()
 {
     $name = new Element('email');
     $name->setLabel('Your email');
     $name->setAttributes(['type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $message = new Element('message');
     $message->setLabel($this->translate('Your question or feedback'));
     $message->setAttributes(['type' => 'textarea', 'class' => 'form-control']);
     $send = new Element('send');
     $send->setValue('Submit');
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($name);
     $this->add($message);
     $this->addCaptcha();
     $this->add($send);
     parent::prepare();
 }
Esempio n. 14
0
 public function __construct()
 {
     $inputFilterForm = new InputFilter();
     parent::__construct('form');
     $this->setInputFilter($inputFilterForm);
     $name = new Element('name');
     $name->setLabel('Your name');
     $name->setAttributes(array('type' => 'text'));
     $inputFilterForm->add(array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
     $email = new Element('email');
     $email->setLabel('Your email');
     $email->setAttributes(array('type' => 'text'));
     $inputFilterForm->add(array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\EmailAddress'))));
     $photo = new Element('photo');
     $photo->setLabel('Your photo');
     $photo->setAttributes(array('type' => 'file'));
     $inputFilterFieldset = new InputFilter();
     // ---------- FieldsetsElements ----------
     $username = new Element('username');
     $username->setLabel('Your username');
     $username->setAttributes(array('type' => 'text'));
     $inputFilterFieldset->add(array('name' => 'username', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
     $inputFilterFieldset->add(array('name' => 'password', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
     $password = new Element('password');
     $password->setLabel('Your password');
     $password->setAttributes(array('type' => 'password'));
     $vpassword = new Element('verify_password');
     $vpassword->setLabel('Verify your password');
     $vpassword->setAttributes(array('type' => 'password'));
     // ---------- FieldsetsElements ----------
     $fieldsetCredential = new Fieldset('id_credential');
     $fieldsetCredential->add($username);
     $fieldsetCredential->add($password);
     $fieldsetCredential->add($vpassword);
     $inputFilterForm->add($inputFilterFieldset, 'id_credential');
     $submit = new Element('submit');
     $submit->setAttributes(array('value' => 'ENVIAR', 'type' => 'submit'));
     // ---------- Formulario ----------
     $this->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
     $this->add($name);
     $this->add($email);
     $this->add($photo);
     $this->add($fieldsetCredential);
     $this->add($submit);
 }
Esempio n. 15
0
 public function prepare()
 {
     $email = new Element('login-email');
     $email->setLabel($this->translate('Email'));
     $email->setAttributes(['id' => 'login-email-standard', 'type' => 'text', 'icon' => 'envelope', 'class' => 'form-control']);
     $password = new Element('login-password');
     $password->setLabel($this->translate('Password'));
     $password->setAttributes(['type' => 'password', 'id' => 'login-password-standard', 'icon' => 'lock', 'class' => 'form-control']);
     $rememberMe = new Checkbox('rememberme');
     $rememberMe->setLabel($this->translate('Remember me'));
     $send = new Element('send');
     $send->setValue('Login');
     $send->setAttributes(['type' => 'submit', 'class' => 'btn btn-default']);
     $this->add($email);
     $this->add($password);
     $this->add($rememberMe);
     $this->add($send);
     parent::prepare();
 }
Esempio n. 16
0
 /**
  * Outputs message depending on flag
  *
  * @return string
  */
 public function __invoke(Element $element)
 {
     $element->setLabelAttributes(array('class' => 'control-label'));
     $element->setAttribute('data-placement', 'bottom')->setAttribute('data-content', $element->getOption('description'));
     if (!$element->getLabel()) {
         $element->setLabel('öö');
     }
     $output = '<div class="control-group">';
     $output .= $this->getView()->formLabel($element);
     $output .= '<div class="controls">';
     $output .= $this->getView()->formElement($element);
     if ($element->getOption('description')) {
         $output .= '<div class="description">' . $element->getOption('description') . '</div>';
     }
     if ($element->getMessages()) {
         $output .= '<div class="alert alert-error">' . $this->getView()->formElementErrors($element) . '</div>';
     }
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
Esempio n. 17
0
 public function formAction()
 {
     // Build a name element.
     $name = new Element('name');
     $name->setLabel('Your name');
     $name->setAttributes(array('type' => 'text'));
     // Build a submit button element.
     $send = new Element('send');
     $send->setLabel('Send');
     $send->setAttributes(array('type' => 'submit', 'value' => 'Send'));
     // Build a checkbox element.
     $check = new Checkbox('check');
     $check->setLabel('Checkbox example');
     // Build a multi-checkbox element.
     $multicheck = new MultiCheckbox('multicheck');
     $multicheck->setLabel('Multi checkbox example');
     $multicheck->setOptions(array('value_options' => array('One' => 'one', 'Two' => 'two')));
     // Assemble the form.
     $form = new Form('contact');
     $form->add($name);
     $form->add($check);
     $form->add($multicheck);
     $form->add($send);
     // Get the request if any.
     $request = $this->getRequest();
     $data = $request->getPost();
     $form->setData($data);
     // Validate the form
     if ($form->isValid()) {
         $validatedData = $form->getData();
         $success = 'Form submit was successful';
     } else {
         $success = 'Form submit failed';
         $messages = $form->getMessages();
     }
     // Set the method attribute for the form
     $form->setAttribute('method', 'post');
     return new ViewModel(array('form' => $form, 'success' => $success, 'messages' => $messages, 'data' => $data));
 }
Esempio n. 18
0
 public function __construct()
 {
     parent::__construct('loginForm');
     $this->setAttributes(array('id' => 'loginForm', 'role' => 'form', 'method' => 'post'));
     $username = new Element('username');
     $username->setLabel('Nombre de Usuario');
     $username->setAttributes(array('type' => 'text', 'placeholder' => 'Escribe tu Nombre de Usuario', 'id' => 'username', 'class' => 'form-control'));
     $password = new Element\Password('password');
     $password->setLabel('Contraseña');
     $password->setAttributes(array('placeholder' => 'Escribe tu Contraseña', 'id' => 'password', 'class' => 'form-control'));
     $remember = new Element\Checkbox('remember');
     $remember->setLabel('Mantener mi sesión activa');
     $remember->setUseHiddenElement(true);
     $remember->setCheckedValue("1");
     $remember->setUncheckedValue("0");
     $remember->setAttributes(array('id' => 'remember'));
     $loginButton = new Element\Button('loginButton');
     $loginButton->setLabel('Inicia Sesión');
     $loginButton->setAttributes(array('class' => 'btn btn-primary', 'type' => 'submit', 'id' => 'loginButton'));
     $this->add($username);
     $this->add($password);
     $this->add($remember);
     $this->add($loginButton);
 }
Esempio n. 19
0
 public function testAppendLabelEvenIfElementHasId()
 {
     $element = new Element('foo');
     $element->setAttribute('id', 'bar');
     $element->setLabel('Baz');
     $this->helper->setLabelPosition('append');
     $markup = $this->helper->render($element);
     $this->assertEquals('<input name="foo" id="bar" type="text" value=""/><label for="bar">Baz</label>', $markup);
 }
Esempio n. 20
0
<?php

use Zend\Captcha;
use Zend\Form\Element;
use Zend\Form\Fieldset;
use Zend\Form\Form;
use Zend\InputFilter\Input;
use Zend\InputFilter\InputFilter;
$name = new Element('name');
$name->setLabel('Your name');
$name->setAttributes(array('type' => 'text'));
$email = new Element\Email('email');
$email->setLabel('Your email address');
$subject = new Element('subject');
$subject->setLabel('Subject');
$subject->setAttributes(array('type' => 'text'));
$message = new Element\Textarea('message');
$message->setLabel('Message');
$captcha = new Element\Captcha('captcha');
$captcha->setCaptcha(new Captcha\Dumb());
$captcha->setLabel('Please verify you are human');
$csrf = new Element\Csrf('security');
$send = new Element('send');
$send->setValue('Submit');
$send->setAttributes(array('type' => 'submit'));
$form = new Form('contact');
$form->add($name);
$form->add($email);
$form->add($subject);
$form->add($message);
$form->add($captcha);
Esempio n. 21
0
 protected function generateFormElementByType($name, $type, $values = array(), $priority)
 {
     switch ($type) {
         case 'FILE':
             $elm = new Element\File();
             $elm->setLabel(strtoupper($name));
             break;
         case 'SELECT':
             $elm = new Element\Select($name);
             $elm->setLabel(strtoupper($name));
             $elm->setAttribute('id', $name . '_ID');
             if ($values instanceof \Traversable || is_array($values)) {
                 $elm->setValueOptions($values);
             }
             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']);
             } 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']);
             } else {
                 $elm = new Element\DateTimeSelect($name);
                 $elm->setLabel(strtoupper($name));
             }
             break;
         default:
             $elm = new Element($name);
             $elm->setLabel(strtoupper($name));
             $elm->setAttributes(array('type' => 'text'));
             break;
     }
     $elm->setOption('priority', $priority);
     return $elm;
 }
Esempio n. 22
0
 /**
  * @param bool $create
  * @return Form
  */
 public function buildForm($create = true)
 {
     $attributes = $this->getHeaders();
     $form = new Form();
     $filter = new InputFilter();
     $validators = array();
     foreach ($attributes as $key => $attribute) {
         $label = isset($attribute['title']) ? $attribute['title'] : ucwords($key);
         $type = isset($attribute['type']) ? $attribute['type'] : 'text';
         switch ($type) {
             case 'text':
                 $element = new Element\Text($key);
                 break;
             case 'int':
                 $element = new Element\Text($key);
                 $validators[] = 'Zend\\Validator\\Digits';
                 $type = 'text';
                 break;
             case 'float':
                 $element = new Element\Text($key);
                 $validators[] = 'Zend\\I18n\\Validator\\Float';
                 $type = 'text';
                 break;
             case 'password':
                 $element = new Element\Password($key);
                 break;
             case 'select':
                 $element = new Element\Select($key);
                 break;
             case 'radio':
                 $element = new Element\Radio($key);
                 break;
             case 'hidden':
                 $element = new Element\Hidden($key);
                 break;
             case 'checkbox':
                 $element = new Element\Checkbox($key);
                 break;
             case 'textarea':
                 $element = new Element\Textarea($key);
                 break;
             case 'wysiwyg':
                 $element = new Element\Textarea($key);
                 break;
             default:
                 $element = new Element($key);
         }
         if ($create === true) {
             if (isset($attribute['create']) && $attribute['create'] === false) {
                 continue;
             }
         } else {
             if (isset($attribute['update']) && $attribute['update'] === false) {
                 continue;
             }
         }
         $element->setLabel($label);
         $element->setAttributes(array('type' => $type));
         if (isset($attribute['options'])) {
             $element->setOptions(array('value_options' => $attribute['options']));
         }
         if (isset($attribute['required']) && $attribute['required'] === true) {
             $validators[] = 'Zend\\Validator\\NotEmpty';
         }
         if (!empty($validators)) {
             foreach ($validators as $validator) {
                 $input = new Input($key);
                 $input->getValidatorChain()->attach(new $validator());
                 $filter->add($input);
             }
         }
         $form->setInputFilter($filter);
         $form->add($element);
     }
     $element = new Element($key);
     $element->setAttributes(array('type' => 'button', 'value' => '<span class="glyphicon glyphicon-chevron-left"></span> Back', 'name' => 'btnBack'));
     $form->add($element);
     $element = new Element($key);
     $element->setAttributes(array('type' => 'submit', 'value' => 'Submit', 'name' => 'btnSubmit'));
     $form->add($element);
     $form->add(array('type' => 'Zend\\Form\\Element\\Csrf', 'name' => 'csrf'));
     return $form;
 }
Esempio n. 23
0
 public function testCanDisableLabelHtmlEscape()
 {
     $element = new Element('foo');
     $element->setLabel('<strong>Click me</strong>');
     $element->setLabelOptions(array('disable_html_escape' => true));
     $markup = $this->helper->__invoke($element);
     $this->assertRegexp('#<button([^>]*)><strong>Click me</strong></button>#', $markup);
 }
Esempio n. 24
0
 /**
  * @param Zend\Form\Element $element
  *
  * @return string
  */
 protected function getElement(Element $element)
 {
     $element->setLabelAttributes(array('class' => 'control-label col-sm-2'));
     $element->setAttribute('data-placement', 'bottom')->setAttribute('class', 'form-control')->setAttribute('data-content', $element->getOption('description'))->setAttribute('data-trigger', 'focus');
     if (!$element->getLabel()) {
         $element->setLabel('öö');
     }
     $output = sprintf('<div class="form-group%1$s">', $element->getMEssages() && !$element instanceof \Zend\Form\Element\Collection ? ' has-error' : '');
     $output .= $this->getView()->formLabel($element);
     $output .= '<div class="col-sm-10">';
     if ($element->getMessages() && !$element instanceof \Zend\Form\Element\Collection) {
         $output .= sprintf('<div class="input-group"><span data-toggle="tooltip" data-placement="bottom" class="input-group-addon" data-html="true" title="%1$s"><i class="fa-warning fa"></i></span>', $this->getView()->formElementErrors($element));
     }
     if ($element instanceof \Zend\Form\Element\Collection) {
         $output .= $this->getView()->formCollection($element);
     } else {
         $output .= $this->getView()->formElement($element);
     }
     if ($element->getMessages()) {
         $output .= '</div>';
     }
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
Esempio n. 25
0
 public function testRenderCanReplaceContent()
 {
     $callback = 'ZendTest\\Form\\Decorator\\TestCallback';
     $element = new Element('foobar');
     $element->setLabel('Label Me');
     $this->decorator->setOptions(array('callback' => $callback, 'placement' => false))->setElement($element);
     $content = $this->decorator->render('foo bar');
     $this->assertNotContains('foo bar', $content, $content);
     $this->assertContains($element->getName(), $content);
     $this->assertContains($element->getLabel(), $content);
 }
Esempio n. 26
0
 public function testCanTranslateContent()
 {
     $element = new Element('foo');
     $element->setLabel('The value for foo:');
     $mockTranslator = $this->getMock('Zend\\I18n\\Translator\\Translator');
     $mockTranslator->expects($this->exactly(1))->method('translate')->will($this->returnValue('translated content'));
     $this->helper->setTranslator($mockTranslator);
     $this->assertTrue($this->helper->hasTranslator());
     $markup = $this->helper->__invoke($element);
     $this->assertContains('>translated content<', $markup);
 }
Esempio n. 27
0
 public function testCanDisableLabelHtmlEscape()
 {
     $element = new Element('foo');
     $element->setLabel('The value <a>for</a> foo:');
     $element->setLabelOptions(array('disable_html_escape' => true));
     $markup = $this->helper->__invoke($element);
     $this->assertContains('<a>for</a>', $markup);
 }
Esempio n. 28
0
 public function testCanAppendLabelContentUsingFlagToInvoke()
 {
     $element = new Element('foo');
     $element->setLabel('The value for foo:');
     $markup = $this->helper->__invoke($element, '<input type="text" id="foo" />', FormLabelHelper::APPEND);
     $this->assertContains('"foo" />The value for foo:</label>', $markup);
     $this->assertContains('for="foo"', $markup);
     $this->assertContains('<label', $markup);
     $this->assertContains('><input type="text" id="foo" />', $markup);
 }
Esempio n. 29
0
 public function testWhenUsingIdAndLabelBecomesEmptyRemoveSpan()
 {
     $element = new Element('foo');
     $element->setLabel('The value for foo:');
     $markup = $this->helper->__invoke($element);
     $this->assertContains('<span', $markup);
     $this->assertContains('</span>', $markup);
     $element->setAttribute('id', 'foo');
     $markup = $this->helper->__invoke($element);
     $this->assertNotContains('<span', $markup);
     $this->assertNotContains('</span>', $markup);
 }
Esempio n. 30
0
 /**
  * @inheritdoc
  */
 public function setLabel($label)
 {
     return $this->element->setLabel($label);
 }