Esempio n. 1
0
 public function __construct()
 {
     parent::__construct();
     $this->setAttribute('method', 'post')->setAttribute('action', '/user/register')->setAttribute('id', 'user-register-form');
     $email = new Email();
     $email->setName('email')->setLabel('Email Address');
     $userName = new Text();
     $userName->setName('userName')->setLabel('Username');
     $password = new Password();
     $password->setName('password')->setLabel('Password');
     $firstName = new Text();
     $firstName->setName('firstName')->setLabel('First Name');
     $lastName = new Text();
     $lastName->setName('lastName')->setLabel('Last Name');
     $csrf = new Csrf();
     $csrf->setName('prev');
     $submit = new Submit();
     $submit->setName('submit')->setValue('Register');
     $this->add($email)->add($userName)->add($password)->add($firstName)->add($lastName)->add($csrf)->add($submit);
     foreach ($this->elements as $element) {
         if (!$element instanceof Submit) {
             $element->setAttribute('class', 'form-control');
         }
     }
 }
Esempio n. 2
0
 public function __construct()
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '/user/login');
     $this->setAttribute('class', 'form');
     $this->setAttribute('id', 'userLoginForm');
     $this->setAttribute('role', 'form');
     $email = new Email();
     $email->setName('email')->setLabel('Email Address')->setAttribute('required', 'true');
     $password = new Password();
     $password->setName('password')->setLabel('Password')->setAttribute('required', 'true');
     $csrf = new Csrf();
     $csrf->setName('prev');
     $checkbox = new Checkbox();
     $checkbox->setName('remember-me');
     $checkbox->setOptions(['use_hidden_element' => false, 'required' => false]);
     $checkbox->setChecked("checked");
     $submit = new Submit();
     $submit->setName('submit')->setValue('Sign In');
     $this->add($email)->add($password)->add($checkbox)->add($csrf)->add($submit);
     foreach ($this->elements as $element) {
         if ($element instanceof Checkbox) {
             $element->setAttributes(['class' => 'custom-checkbox', 'data-toggle' => 'checkbox']);
         } else {
             if ($element instanceof Submit) {
                 $element->setAttributes(['class' => 'btn-inverse btn-large', 'id' => 'loginSubmit']);
             } else {
                 $element->setAttribute('class', 'form-control');
             }
         }
     }
 }
 public function getForm(array $default_status)
 {
     if (!$this->form) {
         $hidId = new Element\Hidden();
         $hidId->setName('userId');
         $txtName = new Element\Text();
         $txtName->setLabel('User Name')->setName("userName")->setAttribute('class', 'form-control');
         $password = new Element\Password();
         $password->setLabel('Password')->setName('password')->setAttribute('class', 'form-control');
         $confirmPassword = new Element\Password();
         $confirmPassword->setName('confirmPassword')->setLabel('Retype Password')->setAttribute('class', 'form-control');
         $selectRole = new Element\Hidden('userRole');
         $description = new Element\Textarea();
         $description->setName('description')->setLabel('Description')->setAttribute('class', 'form-control');
         $status = new Element\Select();
         $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($default_status);
         $image = new Element\File();
         $image->setName('image')->setLabel('Profile image');
         $form = new Form();
         $form->setAttribute('class', 'form-horizontal');
         $form->setAttribute('enctype', 'multipart/form-data');
         $form->add($hidId);
         $form->add($txtName);
         $form->add($password);
         $form->add($confirmPassword);
         $form->add($selectRole);
         $form->add($description);
         $form->add($status);
         $form->add($image);
         $this->form = $form;
     }
     return $this->form;
 }
 public function getForm()
 {
     if (!$this->form) {
         $currentPassword = new Element\Password();
         $currentPassword->setName('currentPassword')->setLabel('Old password')->setAttributes(array('class' => 'form-control'));
         $password = new Element\Password();
         $password->setName('password')->setLabel('New password')->setAttributes(array('class' => 'form-control'));
         $retypePassword = new Element\Password();
         $retypePassword->setName('retypePassword')->setLabel('Retype password')->setAttributes(array('class' => 'form-control'));
         $form = new Form();
         $form->setAttributes(array('class' => 'form-horizontal', 'role' => 'form'));
         $form->add($currentPassword);
         $form->add($password);
         $form->add($retypePassword);
         $this->form = $form;
     }
     return $this->form;
 }
Esempio n. 5
0
 public function addElements()
 {
     $this->setAttributes(array('method' => 'post', 'class' => 'form-horizontal', 'action' => '/admin/users/save'));
     $usrId = new Element\Hidden('usr_id');
     $name = new Element\Text('name');
     $name->setName('name')->setAttribute('placeholder', 'Nome do usuário')->setLabel('Nome do usuário')->setLabelAttributes(array('class' => 'col-sm-2 control-label'));
     $username = new Element\Text('username');
     $username->setName('username')->setAttributes(array('id' => 'username', 'placeholder' => 'Usuário'))->setLabel('Usuário')->setLabelAttributes(array('class' => 'col-sm-2 control-label'));
     $password = new Element\Password('password');
     $password->setName('password')->setAttributes(array('id' => 'password', 'placeholder' => 'Senha'))->setLabel('Senha')->setLabelAttributes(array('class' => 'col-sm-2 control-label'));
     $role = new Element\Select('role');
     $role->setName('role')->setLabel('Perfil de usuário')->setLabelAttributes(array('class' => 'col-sm-2 control-label'))->setValueOptions(array('' => 'Escolha um perfil', 'admin' => 'Administrador', 'redator' => 'Redator'));
     $valid = new Element\Checkbox('valid');
     $valid->setName('valid')->setLabel('Ativar usuário')->setLabelAttributes(array('class' => 'lbl'));
     $submit = new Element\Submit('submit');
     $submit->setAttribute('value', 'Salvar')->setAttribute('class', 'btn btn-primary');
     $this->add($usrId)->add($name)->add($username)->add($password)->add($role)->add($valid)->add($submit);
 }