Exemple #1
0
 /**
  * @param Phalcon\Mvc\ModelInstance $entity
  * @param array $options
  */
 public function initialize($entity = null, $options = null)
 {
     if (!isset($options['edit']) && !isset($options['create'])) {
         $id = new Text('id');
         $id->setLabel('Id');
         $this->add($id);
     }
     $category = new Select('categoriesId', Categories::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...'));
     $category->setLabel('Category');
     $category->addValidator(new PresenceOf(array('message' => 'Category is mandatory')));
     $category->setUserOption('searcheable', true);
     $category->setUserOption('browseable', true);
     $category->setUserOption('relation', 'category');
     $this->add($category);
     $icon = new Text('icon', array('placeholder' => 'Enter a css-icon class name'));
     $icon->setLabel('Icon');
     $icon->addValidator(new PresenceOf(array('message' => 'Icon is mandatory')));
     $this->add($icon);
     $code = new Text('code', array('maxlength' => 10));
     $code->setLabel('Code');
     $code->setUserOption('searcheable', true);
     $code->setUserOption('browseable', true);
     $code->addValidator(new PresenceOf(array('message' => 'Code is mandatory')));
     $this->add($code);
     $name = new Text('name', array('maxlength' => 64));
     $name->setLabel('Name');
     $name->setUserOption('searcheable', true);
     $name->setUserOption('browseable', true);
     $name->addValidator(new PresenceOf(array('message' => 'Name is mandatory')));
     $this->add($name);
     $description = new TextArea('description');
     $description->setLabel('Description');
     $description->addValidator(new PresenceOf(array('message' => 'Description is mandatory')));
     $this->add($description);
     $price = new Text('price');
     $price->setLabel('Price');
     $price->setUserOption('searcheable', true);
     $price->setUserOption('browseable', true);
     $price->addValidator(new PresenceOf(array('message' => 'Price is mandatory')));
     $price->addValidator(new Numericality(array('message' => 'Price must be a number')));
     $this->add($price);
     $stock = new Text('stock');
     $stock->setLabel('Stock');
     $stock->setUserOption('browseable', true);
     $stock->addValidator(new PresenceOf(array('message' => 'Current stock is mandatory')));
     $stock->addValidator(new Numericality(array('message' => 'Current stock must be a number')));
     $this->add($stock);
     if (isset($options['edit'])) {
         $createdAt = new Date('created', array('readonly' => 'readonly'));
         $createdAt->setLabel('Created At');
         if ($entity->createdAt) {
             $entity->created = date('Y-m-d', $entity->createdAt);
         }
         $this->add($createdAt);
     }
 }
Exemple #2
0
 public function initialize()
 {
     $content = new TextArea('content', array('rows' => 35, 'style' => 'display: none;', 'placeholder' => 'Some Markdown text'));
     $content->addValidator(new PresenceOf(array('message' => 'Some content is required')));
     $this->add($content);
     $title = new Text('title', array('placeholder' => 'Title (CamelCase only)', 'autofocus' => true));
     $title->addValidator(new PresenceOf(array('message' => 'A title is required')));
     $title->addValidator(new Regex(array('pattern' => '/[A-Z][a-zA-Z]*/', 'message' => 'Only CamelCase or single word titles are allowed')));
     $this->add($title);
 }
 public function initialize()
 {
     $userName = new Text('userName');
     $userName->addValidator(new PresenceOf(array('message' => 'User name is required')));
     $password = new Password('password');
     $password->addValidator(new PresenceOf(array('message' => 'Password is required')));
     $email = new Text('email');
     $email->addValidator(new PresenceOf(array('message' => 'Email is required')));
     $email->addValidator(new Email(array('message' => 'Email is not valid')));
     $this->add($userName);
     $this->add($password);
     $this->add($email);
 }
Exemple #4
0
 public function initialize()
 {
     $id = new Text("id");
     $id->addValidator(new PresenceOf(array('message' => 'ID can not be empty.')));
     $id->addValidator(new Regex(array('pattern' => '/[a-z0-9_-]+/i', 'message' => 'В ID must be a-z 0-9 _ -')));
     $id->setLabel('ID');
     $title = new Text("title");
     $title->setLabel('Title');
     $html = new TextArea("html");
     $html->setLabel('HTML');
     $this->add($id);
     $this->add($title);
     $this->add($html);
 }
Exemple #5
0
 public function initialize()
 {
     $id = new Text("id");
     $id->addValidator(new PresenceOf(array('message' => 'ID должен быть указан')));
     $id->addValidator(new Regex(array('pattern' => '/[a-z0-9_-]+/i', 'message' => 'В ID могут быть только символы a-z 0-9 _ -')));
     $id->setLabel('ID');
     $title = new Text("title");
     $title->setLabel('Название');
     $html = new TextArea("html");
     $html->setLabel('HTML');
     $this->add($id);
     $this->add($title);
     $this->add($html);
 }
Exemple #6
0
 public function initialize()
 {
     $name = new Text("name");
     $name->setLabel('Name');
     $name->addValidator(new PresenceOf(['message' => '<strong>Name</strong> is required.']));
     $this->add($name);
     $adapter = new Select("adapter", ['Mysql' => 'MySQL']);
     $adapter->setLabel('DB type');
     $this->add($adapter);
     $host = new Text("host");
     $host->setLabel('DB host');
     $host->addValidator(new PresenceOf(['message' => '<strong>DB host</strong> is required.']));
     $this->add($host);
     $user = new Text("username");
     $user->setLabel('DB user');
     $user->addValidator(new PresenceOf(array('message' => '<strong>DB user</strong> is required.')));
     $this->add($user);
     $pass = new Text("password");
     $pass->setLabel('DB pass');
     $this->add($pass);
     $dbname = new Text("dbname");
     $dbname->setLabel('DB name');
     $dbname->addValidator(new PresenceOf(array('message' => '<strong>DB name</strong> is required.')));
     $this->add($dbname);
     //$this->setCsrf();
 }
Exemple #7
0
 public function initialize()
 {
     $login = new Text('login');
     $login->addValidator(new PresenceOf(array('message' => $this->helper->translate('Login is required'))));
     $password = new Password('password');
     $password->addValidator(new PresenceOf(array('message' => $this->helper->translate('Password is required'))));
 }
Exemple #8
0
 public function testArrayedValues()
 {
     $model = new FakeModel();
     $values = array('integer' => '3 14', 'test1' => array(2 => 'foo', 3 => 'bar'), 'test2' => array('en' => 'baz', 'nl' => 123.4), 'test3' => array(array(0 => 'doubleArrayed', 1 => array(0 => 'tripleArrayed'))), 'not_in_form' => array('some_value'));
     $form = new Form();
     $text = new Text('integer');
     $text->addFilter('int');
     $form->add($text);
     $form->add(new Text('test1[]'));
     $form->add(new Text('test1[]'));
     $text = new Text('test2[en]');
     $text->addValidator(new PresenceOf());
     $form->add($text);
     $text = new Text('test2[nl]');
     $text->addFilter('int');
     $form->add($text);
     $form->add(new Text('test3[0][]'));
     $form->add(new Text('test3[0][1][]'));
     $form->bind($values, $model);
     $this->assertTrue($form->isValid());
     $this->assertTrue(!isset($model->not_in_form));
     $this->assertEquals('3 14', $form->getValue('integer'));
     $this->assertEquals(314, $model->integer);
     $this->assertEquals($model->test1[0], $form->getValue('test1[2]'));
     $this->assertEquals($model->test1[1], $form->getValue('test1[3]'));
     $this->assertNull($form->getValue('test1[]'));
     $this->assertNull($form->getValue('test1[1]'));
     $this->assertEquals($model->test2['en'], $form->getValue('test2[en]'));
     $this->assertEquals(123.4, $form->getValue('test2[nl]'));
     $this->assertEquals(1234, $model->test2['nl']);
     $this->assertNull($form->getValue('test2[en][notexsiting]'));
     $this->assertEquals($model->test3[0][0], $form->getValue('test3[0][0]'));
     $this->assertEquals($model->test3[0][1][0], $form->getValue('test3[0][1][0]'));
 }
 public function initialize()
 {
     //username
     $username = new Text('login');
     $username->setLabel('Login');
     $username->addValidator(new PresenceOf(array("message" => "Login required")));
     $username->setAttributes(array('id' => 'login-username', 'class' => 'form-control', 'placeholder' => 'username'));
     $this->add($username);
     //password
     $password = new Password('password');
     $password->setLabel('Password');
     $password->addValidator(new PresenceOf(array("message" => "Password required")));
     $password->setAttributes(array('id' => 'login-password', 'class' => 'form-control', 'placeholder' => 'password'));
     $password->clear();
     $this->add($password);
     //remember me
     $remember = new Check('remember', array("value" => '1', "id" => "login-remember"));
     $remember->setLabel('Remember me');
     $this->add($remember);
     //CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical([$this->security->checkToken() => true, 'message' => 'This request was aborted because it appears to be forged']));
     $this->add($csrf);
     //Submit
     $this->add(new Submit('Sign In', array('class' => 'btn btn-success', 'id' => 'btn-login')));
 }
 public function initialize()
 {
     $type = new Select('type_id', Type::cachedListArray(['key' => 'id']));
     $type->setLabel('Type of Publication');
     $this->add($type);
     $title = new Text('title', ['required' => true]);
     $title->addValidator(new PresenceOf(['message' => 'Title can not be empty']));
     $title->setLabel('Title');
     $this->add($title);
     $slug = new Text('slug');
     $slug->setLabel('Slug');
     $this->add($slug);
     $date = new Text('date');
     $date->setLabel('Publication Date');
     $this->add($date);
     $text = new TextArea('text');
     $text->setLabel('Text');
     $this->add($text);
     $meta_title = new Text('meta_title', ['required' => true]);
     $meta_title->setLabel('meta-title');
     $this->add($meta_title);
     $meta_description = new TextArea('meta_description', ['style' => 'height:4em; min-height: inherit']);
     $meta_description->setLabel('meta-description');
     $this->add($meta_description);
     $meta_keywords = new TextArea('meta_keywords', ['style' => 'height:4em; min-height: inherit']);
     $meta_keywords->setLabel('meta-keywords');
     $this->add($meta_keywords);
     $preview_inner = new Check('preview_inner');
     $preview_inner->setLabel('Show preview image inside publication');
     $this->add($preview_inner);
     $image = new Image('preview_src');
     $image->setLabel('Thumbnail Image');
     $this->add($image);
 }
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     //title
     $link = new Text('link', array('class' => 'form-control', 'required' => true));
     $link->addValidator(new PresenceOf(array('message' => t('The link is required.'))));
     $this->add($link);
     //content
     $content = new Textarea('content', array('placeholder' => t('Adding information for link your submit!'), 'class' => 'wmd-input', 'id' => 'wmd-input', 'required' => true, 'rows' => 10));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success', 'value' => t('Submit Link'))));
 }
 public function initialize($model = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     // $this->add(new Select('status', array('0'=>'Không', '1'=>'Có')));
     $this->add(new Select('featured', array('0' => 'Không', '1' => 'Có')));
     $this->add(new Text("image"));
     $this->add(new TextArea("description"));
     $this->add(new TextArea("content"));
     // Config tab
     $this->add(new Text("link"));
     $this->add(new Select('url_target', array('normal' => 'Bình thường', '_blank' => 'Mở trang mới')));
     $this->add(new Text("published", array('data-format' => 'yyyy-MM-dd hh:mm:ss', 'value' => date('d-m-Y H:i:s'))));
     $this->add(new Text("position"));
     // SEO tab
     $this->add(new Text("seo_title"));
     $this->add(new TextArea("metadata"));
     $this->add(new TextArea("keyword"));
     $result = \Modules\Backend\Models\News_category::find();
     $system = new \Modules\Library\System();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, "title");
     $category_id = new Select('category_id', $record);
     $this->add($category_id);
 }
Exemple #13
0
 /**
  * attach the username field with validators
  */
 protected function attachUsername()
 {
     $username = new Text('username');
     $username->addValidator(new PresenceOf(['message' => 'The username is required']));
     $this->username = $username;
     $this->formElements['username'] = $username;
 }
Exemple #14
0
 public function initialize($model, $menu_id = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'name')));
     $this->add($name);
     $this->add(new Text("code"));
     $link = new Text("link");
     $link->addValidator(new PresenceOf(array('message' => 'link')));
     $this->add($link);
     // parents menu item
     $result = \Modules\Backend\Models\Menu_item::findByMenu_id($menu_id);
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $data = $system->getListTreeCategory($data, 'name');
     $parents = new Select('parents', $data);
     $this->add($parents);
     $tbl_menu = \Modules\Backend\Models\Menu::find();
     $menu = new Select('menu_id', $tbl_menu, array('using' => array('id', 'name')));
     $menu->setDefault($menu_id);
     $this->add($menu);
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $target = new Select('target', array('0' => 'Bình thường', '1' => 'Mở tab mới'));
     $this->add($target);
     $this->add(new Text("image"));
     $this->add(new Text("position"));
 }
Exemple #15
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('Title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     // In edit page the id is hidden
     if (!empty($entity)) {
         $checked = null;
         $this->add(new Radio('locked', ['value' => 'Y', 'checked' => $checked, 'name' => 'locked']));
         if ($entity->getLocked() == 'N') {
             $checked = 'checked';
         }
         $this->add(new Radio('unLocked', ['value' => 'N', 'checked' => $checked, 'name' => 'locked']));
     } else {
         $this->add(new Radio('locked', ['value' => 'Y', 'name' => 'locked']));
         $this->add(new Radio('unLocked', ['value' => 'N', 'name' => 'locked']));
     }
     //content
     $content = new Textarea('content', array('placeholder' => t('Please be sure to answer the question. Provide details and share your research!'), 'class' => 'wmd-input', 'id' => 'wmd-input', 'required' => true, 'rows' => 10));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success', 'value' => t('Submit Post'))));
 }
Exemple #16
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     $tags = new Hidden('tags', array('required' => true));
     $tags->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($tags);
     //content
     $content = new Textarea('content', array('placeholder' => t('Please be sure to answer the question. Provide details and share your research!'), 'class' => 'wmd-input', 'id' => 'wmd-input', 'required' => true, 'rows' => 10));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success', 'value' => t('Submit Post'))));
 }
Exemple #17
0
 public function initialize()
 {
     // Username
     $username = new Text('username', ['placeholder' => 'Username']);
     $username->addValidator(new PresenceOf(['message' => 'The username is required']));
     $this->add($username);
     // Password
     $password = new Password('password', ['placeholder' => 'Password']);
     $password->addValidator(new PresenceOf(['message' => 'The password is required']));
     $this->add($password);
     // Remember
     $remember = new Check('remember', ['value' => 'yes']);
     $remember->setLabel('Remember me');
     $this->add($remember);
     /*// CSRF
             $csrf = new Hidden('csrf');
     
             $csrf->addValidator(new Identical(array(
                 'value' => $this->security->getSessionToken(),
                 'message' => 'CSRF validation failed'
             )));
     
             $this->add($csrf);
     
             $this->add(new Submit('go', array(
                 'class' => 'btn btn-success'
             )));*/
 }
 public function initialize()
 {
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'name')));
     $this->add($name);
     $this->add(new Select('status', array('0' => 'Không', '1' => 'Có'), array('class' => 'medium')));
     $this->add(new Text("position", array('class' => 'txt_medium')));
 }
Exemple #19
0
 public function initialize()
 {
     $login = new Text('login', array('required' => true, 'placeholder' => 'Enter login'));
     $login->addValidator(new PresenceOf(array('message' => 'Login is required')));
     $this->add($login);
     $password = new Password('password', array('required' => true));
     $password->addValidator(new PresenceOf(array('message' => 'Password is required')));
     $this->add($password);
 }
Exemple #20
0
 /**
  * Init form
  *
  * @param \ZCMS\Core\Models\MenuItems $data
  */
 public function initialize($data = null)
 {
     $name = new Text("name");
     $name->addValidator(new PresenceOf());
     $this->add($name);
     $description = new TextArea("description");
     $this->add($description);
     $published = new Select("published", ["1" => __("gb_yes"), "0" => __("gb_no")]);
     $this->add($published);
 }
Exemple #21
0
 public function initialize()
 {
     $login = new Text('login', array('maxlength' => 16));
     $login->addValidator(new PresenceOf(array('message' => 'User name is required')));
     $login->setLabel('Login');
     $this->add($login);
     $password = new Password('password');
     $password->addValidator(new PresenceOf(array('message' => 'Password is required')));
     $password->setLabel('Password');
     $this->add($password);
 }
 public function initialize()
 {
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'name')));
     $this->add($name);
     $this->add(new Select("permission", array("full" => "Full", "limit" => "Limit"), array('class' => 'medium')));
     $this->add(new Select('status', array('0' => 'Không', '1' => 'Có'), array('class' => 'medium')));
     $this->add(new Text("position", array('class' => 'txt_medium')));
     $resource_id = new Select('resource_id', \Modules\Backend\Models\Permission_resource::find(), array('using' => array('id', 'name'), 'class' => 'medium'));
     $this->add($resource_id);
 }
Exemple #23
0
 public function initialize($entity = null, $options = array())
 {
     $name = new Text('name', array('maxlength' => 100, 'placeholder' => 'Nombre del sub-tema', 'required' => 'required', 'class' => 'form-control', 'autofocus' => 'autofocus', 'id' => 'name'));
     $name->setLabel("*Nombre del sub-tema");
     $name->addValidator(new SpaceValidatorForm(array('message' => 'El campo nombre se encuentra vacío')));
     $name->addValidator(new StringLength(array('min' => 2, 'messageMinimum' => 'El nombre del sub-tema es demasiado corto, debe tener al menos 2 carateres', 'max' => 800, 'messageMaximum' => 'El nombre del sub-tema es demasiado largo, debe tener máximo 800 carateres')));
     $this->add($name);
     $description = new TextArea('description', array('maxlength' => 100, 'placeholder' => 'Descripción', 'class' => 'form-control', 'rows' => 5, 'id' => 'description'));
     $description->setLabel("Descripción");
     $this->add($description);
     $checked = "checked";
     $value = "1";
     if ($entity) {
         $checked = $entity->status ? "checked" : "";
         $value = $entity->status;
     }
     $status = new Check('status', array('id' => 'status', 'class' => 'onoffswitch-checkbox', "value" => $value, $checked => $checked));
     $status->setLabel("*Estado");
     $this->add($status);
 }
Exemple #24
0
 public function initialize()
 {
     $email = new Text('email');
     $email->addValidator(new PresenceOf());
     $email->addValidator(new EmailValidator());
     $email->setAttribute('placeholder', '*****@*****.**');
     $email->setAttribute('class', 'col-xs-12');
     $email->setLabel($this->i18n->_('Email'));
     $this->add($email);
     $password = new Password('raw_password');
     $password->addValidator(new PresenceOf());
     $password->setLabel($this->i18n->_('Password'));
     $password->setAttribute('class', 'col-xs-12');
     $this->add($password);
     $rePassword = new Password('repassword');
     $rePassword->addValidator(new PresenceOf());
     $rePassword->setLabel($this->i18n->_('Re-type Password'));
     $rePassword->setAttribute('class', 'col-xs-12');
     $this->add($rePassword);
 }
Exemple #25
0
 public function initialize()
 {
     $email = new Text("email");
     $email->setLabel('Email');
     $email->addValidator(new PresenceOf(['message' => '<strong>Email</strong> address is required.']));
     $this->add($email);
     $type = new Select('type', ['master' => 'master', 'operator' => 'operator']);
     $type->setLabel('Type');
     $type->setDefault('operator');
     $this->add($type);
     //$this->setCsrf();
 }
Exemple #26
0
 /**
  * Init form
  *
  * @param \ZCMS\Core\Models\SlideShows $data
  */
 public function initialize($data = null)
 {
     $title = new Text('title', ['required' => 'required']);
     $title->addValidator(new PresenceOf(['message' => 'Please typing title']));
     $this->add($title);
     $alias = new Text('alias');
     $this->add($alias);
     $description = new TextArea('description', ['rows' => 5]);
     $this->add($description);
     $published = new Select('published', ['1' => __('gb_published'), '0' => __('gb_unpublished')], ['value' => $data != null ? $data->published : 1]);
     $this->add($published);
 }
 public function initialize()
 {
     // Elemente instanzieren
     $name = new Text('name');
     $recaptcha = new ReCaptchaElement('recaptcha');
     // Validator für Name-Feld
     $name->addValidator(new PresenceOf(array('message' => 'Bitte Namen eingeben')));
     // Validator für ReCaptcha
     $recaptcha->addValidator(new ReCaptchaValidator(array('message' => 'Bitte ReCaptcha ausfüllen')));
     // Elemente zum Formular hinzufügen
     $this->add($name);
     $this->add($recaptcha);
 }
 public function initialize()
 {
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'name')));
     $this->add($name);
     $controller = new Text("controller");
     $controller->addValidator(new PresenceOf(array('message' => 'controller')));
     $this->add($controller);
     $action = new Text("action");
     $action->addValidator(new PresenceOf(array('message' => 'action')));
     $this->add($action);
     $position = new Text("position");
     $this->add($position);
 }
 public function initialize()
 {
     $environment = $this->config['application']['debug'] ? 'development' : 'production';
     $baseUri = $this->config['application'][$environment]['staticBaseUri'];
     $this->setAction($baseUri . 'session/start/');
     $username = new Text('username');
     $username->addValidator(new PresenceOf(array('message' => 'Can\'t be empty')));
     $password = new Password('password');
     $password->addValidator(new PresenceOf(array('message' => 'Can\'t be empty')));
     $submit = new Submit('login', array('value' => 'Login'));
     $this->add($username);
     $this->add($password);
     $this->add($submit);
 }
Exemple #30
-1
 /**
  * Init user form
  *
  * @param \ZCMS\Core\Models\Users $data
  */
 public function initialize($data = null)
 {
     //Add first name
     $firstName = new Text('first_name', ['maxlength' => '32']);
     $firstName->addValidator(new PresenceOf());
     $this->add($firstName);
     //Add last name
     $lastName = new Text('last_name', ['maxlength' => '32']);
     $lastName->addValidator(new PresenceOf());
     $this->add($lastName);
     //Add email
     if ($data = null) {
         $email = new Email('email', ['maxlength' => '128', 'readonly' => 'readonly']);
     } else {
         $email = new Email('email', ['maxlength' => '128']);
     }
     $this->add($email);
     //Add active
     $is_active = new Select('is_active', ['1' => __('gb_yes'), '0' => __('gb_no')]);
     $this->add($is_active);
     //Add password confirmation
     $password_confirmation = new Password('password_confirmation', ['maxlength' => '32']);
     $password_confirmation->addValidator(new StringLength(['min' => 6]));
     $this->add($password_confirmation);
     //Add password
     $password = new Password('password', ['maxlength' => '32']);
     $password->addValidator(new StringLength(['min' => 6]));
     $password->addValidator(new Confirmation(['message' => 'm_system_user_message_password_does_not_match_confirmation', 'with' => 'password_confirmation']));
     $this->add($password);
     //Add role
     $dbRoles = UserRoles::find(['conditions' => 'is_super_admin = 0', 'order' => 'is_default DESC']);
     $role = new Select('role_id', $dbRoles, ['using' => ['role_id', 'name']]);
     $role->addValidator(new InclusionIn(['message' => 'm_system_user_message_please_choose_role', 'domain' => array_column($dbRoles->toArray(), 'role_id')]));
     $this->add($role);
 }