Example #1
0
 public function __construct(EntityManager $em, OrmPublicador $publicador = null, OrmLogin $orm = null)
 {
     parent::__construct("formLogin");
     //       var_dump($option);
     //       exit();
     /*
      * txtID
      */
     $txtId = new Element\Hidden("id");
     /*
      * txtNome
      */
     $txtEmail = new Element\Email("email");
     $txtEmail->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'data-parsley-trigger' => 'change', 'required' => 'true'));
     /*
      *  txtSenha
      */
     $txtSenha = new Element\Password("senha");
     $txtSenha->setAttributes(array('id' => "senha", 'class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'required' => 'true', "data-parsley-trigger" => "change", "data-parsley-length" => "[6, 20]"));
     /*
      * txtSenhaConfirma
      */
     $txtSenhaConfirma = new Element\Password("senhaconfirmar");
     $txtSenhaConfirma->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Grupo', 'required' => 'true', "data-parsley-trigger" => "change", "data-parsley-equalto" => "#senha"));
     /*
      * cmbPublicador
      */
     $dao = $em->getRepository('Stj\\Entity\\OrmPublicador');
     if (empty($publicador)) {
         $lista = $dao->findAll();
     } else {
         $lista = $dao->ListALLWhere($publicador->getGrupo()->getCongregacao()->getId());
     }
     $option = array();
     foreach ($lista as $key => $value) {
         $publicador = new OrmPublicador();
         $publicador = $value;
         $option[$publicador->getId()] = $publicador->getNome();
     }
     $cmbPublicador = new Element\Select('publicador');
     $cmbPublicador->setValueOptions($option);
     $cmbPublicador->setEmptyOption("Selecionar");
     $cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true'));
     /*
      * cmbNivel
      */
     $dao = $em->getRepository('Stj\\Entity\\OrmNivel');
     $lista = $dao->ListALL(FALSE);
     $option = array();
     foreach ($lista as $key => $value) {
         $nivel = new OrmNivel();
         $nivel = $value;
         $option[$nivel->getId()] = $nivel->getNome();
     }
     $cmbNivel = new Element\Select('nivel');
     $cmbNivel->setValueOptions($option);
     $cmbNivel->setEmptyOption("Selecionar");
     $cmbNivel->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true'));
     /*
      * Itoken
      */
     $iToken = new Element\Csrf("iToken");
     /*
      * btnSalvar
      */
     $btnSalvar = new Element\Button('salvar');
     $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
     /*
      * btnVoltar
      */
     $btnVoltar = new Element\Button('voltar');
     $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
     /*
      * Preencher Componentes
      */
     if ($orm != null) {
         $txtId->setValue($orm->getId());
         $txtEmail->setValue($orm->getEmail());
         $cmbPublicador->setValue($orm->getPublicador()->getId());
         $cmbNivel->setValue($orm->getNivel()->getId());
     }
     // Adiciona componetes no form
     $this->add($txtId);
     $this->add($txtEmail);
     $this->add($txtSenha);
     $this->add($txtSenhaConfirma);
     $this->add($cmbPublicador);
     $this->add($cmbNivel);
     $this->add($iToken);
     $this->add($btnSalvar);
     $this->add($btnVoltar);
     $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL));
 }