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')))); }
public function initialize() { $email = new Text('email'); $email->setLabel('Email'); $email->addValidators([new PresenceOf(['message' => 'The email is required', 'cancelOnFail' => true]), new Email(['message' => 'Must be a valid email'])]); $this->add($email); $firstName = new Text('first-name'); $firstName->setLabel('First Name'); $firstName->addValidators([new PresenceOf(['message' => 'The first name is required', 'cancelOnFail' => true]), new StringLength(['min' => 3, 'max' => 40, 'messageMinimum' => 'The first name is too short. Minimum 3 characters', 'messageMaximum' => 'The first name is too long. Maximum 40 characters'])]); $this->add($firstName); $lastName = new Text('last-name'); $lastName->setLabel('Last Name'); $lastName->addValidators([new PresenceOf(['message' => 'The last name is required', 'cancelOnFail' => true]), new StringLength(['min' => 3, 'max' => 40, 'messageMinimum' => 'The last name is too short. Minimum 3 characters', 'messageMaximum' => 'The last name is too long. Maximum 40 characters'])]); $this->add($lastName); $middleName = new Text('middle-name'); $middleName->setLabel('Middle Name'); $middleName->addValidators([new StringLength(['max' => 40, 'messageMaximum' => 'The middle name is too long. Maximum 40 characters'])]); $this->add($middleName); $password = new Password('password'); $password->setLabel('Password'); $password->addValidators([new PresenceOf(['message' => 'The password is required', 'cancelOnFail' => true]), new StringLength(array('min' => 8, 'messageMinimum' => 'Password is too short. Minimum 8 characters')), new Regex(['pattern' => '/^(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).*$/', 'message' => 'The password is not strong enough. It must contain both upper, lowercase characters and at least one digit']), new Confirmation(array('message' => 'The password does not match it\'s confirmation', 'with' => 'password-confirm'))]); $this->add($password); $confirm = new Password('password-confirm'); $confirm->setLabel('Confirm password'); $confirm->addValidators([new PresenceOf(['message' => 'The password confirmation is required'])]); $this->add($confirm); $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); }
/** * Set a csrf token for all forms * * @return Hidden */ protected function attachCsrf() { $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(['value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'])); $csrf->clear(); return $csrf; }
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($entity = null, $options = null) { //name $name = new Text('name'); $name->setLabel('Представьтесь или напишите название Вашего приюта:'); $name->addValidators(array(new PresenceOf(array('message' => 'Обязательное поле')))); $this->add($name); //email $email = new Text('email'); $email->setLabel('Введите Ваш E-mail:'); $email->addValidators(array(new PresenceOf(array('message' => 'Обязательное поле')), new Email(array('message' => 'Введите правильный E-mail')))); $this->add($email); //Phone $number = new Text('number'); $number->setLabel('Напишите телефон, по которому с Вами можно связаться:'); $number->addValidators(array(new PresenceOf(array('message' => 'Обязательное поле')))); $this->add($number); //password $password = new Password('password'); $password->setLabel('Придумайте пароль:'); $password->addValidators(array(new PresenceOf(array('message' => 'Обязательно поле')), new StringLength(array('min' => 8, 'messageMinimum' => 'Слишком короткий, минимум - 8 символов')), new Confirmation(array('message' => 'Пароль не подтвержден', 'with' => 'confirmPassword')))); $this->add($password); // Confirm Password $confirmPassword = new Password('confirmPassword'); $confirmPassword->setLabel('Подтвердите пароль:'); $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required')))); $this->add($confirmPassword); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); // Sign Up $this->add(new Submit('Sign Up', array('class' => 'btn btn-success'))); }
public function initialize($entity = null, $options = null) { if (isset($options['edit']) && $options['edit']) { $id = new Hidden('id'); } else { $id = new Text('id'); } $username = new Text('username', array('placeholder' => 'Tran Duy Thien')); //<input type="text" value="" id="fullName" name="fullName"> $username->setLabel('Tên Tài Khoản'); //<label for="fullName">fullName</label> $username->addValidators(array(new PresenceOf(array('message' => 'Tài khoản không được rỗng')))); $this->add($username); //Password $password = new Password('password'); $password->setLabel('Mật Khẩu'); $password->addValidators(array(new PresenceOf(array('message' => 'Mật khẩu không được rỗng')), new StringLength(array('min' => 8, 'messageMinimum' => 'Mật khẩu phải lớn hơn 8 ký tự')), new Confirmation(array('message' => 'Mật khẩu không khớp', 'with' => 'confirmPassword')))); $this->add($password); //Confirm Password $confirmPassword = new Password('confirmPassword'); $confirmPassword->setLabel('Nhập lại mật khẩu'); $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required')))); $this->add($confirmPassword); //Remember $terms = new Check('terms', array('value' => 'yes')); $terms->setLabel('Đồng ý với Điều khoản dịch vụ và chính sách bảo mật của chúng tôi'); $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Bạn chưa chọn'))); $this->add($terms); //CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); //Sign Up $this->add(new Submit('Sign Up', array('class' => 'btn btn-primary pull-right'))); }
public function initialize($entity = null, $options = null) { $name = new Text('name'); $name->setLabel('Name'); $name->addValidators(array(new PresenceOf(array('message' => 'The name is required')))); $this->add($name); //Email $email = new Text('email'); $email->setLabel('E-Mail'); $email->addValidators(array(new PresenceOf(array('message' => 'The e-mail is required')), new Email(array('message' => 'The e-mail is not valid')))); $this->add($email); //Password $password = new Password('password'); $password->setLabel('Password'); $password->addValidators(array(new PresenceOf(array('message' => 'The password is required')), new StringLength(array('min' => 8, 'messageMinimum' => 'Password is too short. Minimum 8 characters')), new Confirmation(array('message' => 'Password does not match confirmation', 'with' => 'confirmPassword')))); $this->add($password); //Confirm Password $confirmPassword = new Password('confirmPassword'); $confirmPassword->setLabel('Confirm Password'); $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required')))); $this->add($confirmPassword); //Remember $terms = new Check('terms', array('value' => 'yes')); $terms->setLabel('Accept terms and conditions'); $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Terms and conditions must be accepted'))); $this->add($terms); //CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); //Sign Up $this->add(new Submit('Register', array('class' => 'btn btn-success'))); }
public function initialize($categoryEntity = null, $options = null) { //The $options['edit'] variable is passed true though the CategoriesController editAction. //To create a new category null is passed to $options though addAction if (isset($options['edit']) && $options['edit'] === true) { $this->edit = true; } //Get all the locales from the global configuration $locales = $this->getDI()->get('config')->i18n->locales->toArray(); //Creates a name and slug text for each locale specified in our global configuration //The category names will be returned from the post request as //translations['en'][category_translation_name], translations['gr'][category_translation_name] etc... foreach ($locales as $locale => $language) { if (true === $this->edit) { //Ex: Queries category_translation table for category_translation_lang = 'en' $translations = $categoryEntity->getTranslations(["category_translation_lang = '{$locale}'"])->toArray(); } $category_name[$locale] = new Text("translations[{$locale}][category_translation_name]", ['value' => $this->edit === true ? $translations[0]['category_translation_name'] : null]); $category_slug[$locale] = new Text("translations[{$locale}][category_translation_slug]", ['value' => $this->edit === true ? $translations[0]['category_translation_slug'] : null]); $category_lang[$locale] = new Hidden("translations[{$locale}][category_translation_lang]", ['value' => $locale]); $this->add($category_name[$locale]); $this->add($category_slug[$locale]); $this->add($category_lang[$locale]); } //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-lg btn-primary btn-block'))); }
public function initialize($entity = null, $options = null) { // In edition the id is hidden if (isset($options['edit']) && $options['edit']) { $id = new Hidden('id'); } else { $id = new Text('id'); } $this->add($id); $brand = new Text('brand', array('placeholder' => 'Brand')); $brand->addValidators(array(new PresenceOf(array('message' => 'The brand is required')))); $this->add($brand); $model = new Text('model', array('placeholder' => 'Model')); $model->addValidators(array(new PresenceOf(array('message' => 'The model is required')))); $this->add($model); $cc = new Text('cc', array('placeholder' => 'CC')); $this->add($cc); $color = new Text('color', array('placeholder' => 'Color')); $color->addValidators(array(new StringLength(array('max' => 50, 'messageMaximum' => 'Color is too long. Miximum 50 characters')))); $this->add($color); $weight = new Text('weight', array('placeholder' => 'Weight')); $this->add($weight); $price = new Text('price', array('placeholder' => 'Price')); $price->addValidators(array(new PresenceOf(array('message' => 'The price is required')))); $this->add($price); $image = new File('image', array('placeholder' => 'Image')); $this->add($image); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); // Add button $this->add(new Submit('Add', array('class' => 'btn btn-success'))); }
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() { $content = new TextArea('content', array('rows' => 35, 'style' => 'display: none', 'spellcheck' => 'false')); $content->addValidator(new PresenceOf(array('message' => 'Some content is required'))); $this->add($content); $id = new Hidden('id'); $id->addValidator(new Regex(array('pattern' => '/[0-9]*/', 'message' => 'The page id can only be numerical'))); $this->add($id); }
public function initialize() { $file = new File('avatar'); $this->add($file); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed')))); $this->add($csrf); $this->add(new Submit('changeAvatar', ['value' => 'Change avatar', 'class' => 'btn btn-sm btn-info'])); }
public function initialize() { $analytic = new Text('analytic', ['placeholder' => t('Google Analytic'), 'class' => 'form-control', 'value' => $this->config->googleAnalytic]); $this->add($analytic); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed')))); $this->add($csrf); $this->add(new Submit('save', ['value' => 'Change analytic', 'class' => 'btn btn-sm btn-info'])); }
public function initialize() { $email = new Text('email'); $email->setLabel('Email*'); $email->addValidators([new PresenceOf(['message' => 'The email is required', 'cancelOnFail' => true]), new Email(['message' => 'Must be a valid email'])]); $this->add($email); $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); }
public function initialize($entity = null, $options = null) { $hashtag_name = new Text('hashtag_name', array('placeholder' => 'Name')); $hashtag_name->addValidators(array(new PresenceOf(array('message' => 'Name is required')))); $this->add($hashtag_name); //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-lg btn-primary btn-block'))); }
public function initialize() { //Email $email = new Text('email', ['placeholder' => 'Email', 'class' => 'form-control', 'required' => 'true', 'autofocus' => 'true']); $email->addValidators([new PresenceOf(['message' => 'The e-mail is required']), new Email(['message' => 'The e-mail is not valid'])]); $this->add($email); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); //Submit $this->add(new Submit('recover', ['class' => 'submit-button-login', 'value' => 'Recover'])); }
public function initialize() { // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed')))); $this->add($csrf); $unauthor = new Submit('unauthor', ['name' => 'unauthor', 'value' => 'Go to setting', 'class' => 'btn btn-sm btn-warning']); $unauthor->setLabel("This feature need to be configured"); $this->add($unauthor); $profile = new Submit('profile', ['name' => 'profile', 'value' => 'Go to setting', 'class' => 'btn btn-sm btn-warning']); $profile->setLabel("You must select view before use this feature"); $this->add($profile); }
public function initialize($entity = null, $options = null) { if (isset($options['edit']) && $options['edit'] === true) { $this->edit = true; } $locales = $this->getDI()->get('config')->i18n->locales->toArray(); foreach ($locales as $locale => $name) { if (true === $this->edit) { $translations = $entity->getTranslations(["article_translation_lang = '{$locale}'"])->toArray(); } $article_translation_short_title[$locale] = new Text("translations[{$locale}][article_translation_short_title]", ['value' => $this->edit === true ? $translations[0]['article_translation_short_title'] : null]); $article_translation_long_title[$locale] = new Text("translations[{$locale}][article_translation_long_title]", ['value' => $this->edit === true ? $translations[0]['article_translation_long_title'] : null]); $article_translation_description[$locale] = new TextArea("translations[{$locale}][article_translation_description]", ['value' => $this->edit === true ? $translations[0]['article_translation_description'] : null]); $article_translation_slug[$locale] = new Text("translations[{$locale}][article_translation_slug]", ['value' => $this->edit === true ? $translations[0]['article_translation_slug'] : null]); $article_translation_lang[$locale] = new Hidden("translations[{$locale}][article_translation_lang]", ['value' => $locale]); $this->add($article_translation_short_title[$locale]); $this->add($article_translation_long_title[$locale]); $this->add($article_translation_description[$locale]); $this->add($article_translation_slug[$locale]); $this->add($article_translation_lang[$locale]); } // Categories $categories = new Select('categories[]', CategoryTranslation::find(["category_translation_lang = 'en'"]), ['using' => ['category_translation_category_id', 'category_translation_name'], 'multiple' => true]); if ($this->edit === true) { $categories_defaults = array(); foreach ($entity->getCategories(["columns" => ["id"]]) as $category) { $categories_defaults[] = $category->id; } $categories->setDefault($categories_defaults); } $this->add($categories); // Hash tags $hashtags = new Select('hashtags[]', Hashtag::find(), ['using' => ['id', 'hashtag_name'], 'multiple' => true]); if ($this->edit === true) { $hashtags_defaults = array(); foreach ($entity->getHashtags(["columns" => ["id"]]) as $hashtag) { $hashtags_defaults[] = $hashtag->id; } $hashtags->setDefault($hashtags_defaults); } $this->add($hashtags); // Is published $this->add(new Select('article_is_published', array(1 => 'Yes', 0 => 'No'))); //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-lg btn-primary btn-block'))); }
public function initialize() { $file = new File('media'); $this->add($file); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(['value' => $this->security->getSessionToken(), 'message' => $this->constants->csrfError()])); // Display for type of media. Such as images, videos, audios, etc $totalMedia = MediaType::sum(["column" => "amount"]); $mediaType = new Select("mediaType", MediaType::find(['columns' => array('id', " CONCAT(name, ' (', amount, ')') as type_amount")]), ['using' => ['id', 'type_amount'], 'name' => 'mediaType', 'class' => 'form-control col-md-3 btn-mini', 'useEmpty' => true, 'emptyText' => "All (" . $totalMedia . ")", 'emptyValue' => "all"]); $this->add($mediaType); // Search some thing $search = new Text('search', ['placeholder' => $this->constants->searchPlaceHolder(), 'class' => 'form-control btn-mini', 'required' => false]); $this->add($search); }
public function initialize() { $email = new Text('email', array('placeholder' => 'Email', 'class' => 'form-control')); $email->addValidators(array(new PresenceOf(array('message' => 'The e-mail is required')), new Email(array('message' => 'The e-mail is not valid')))); $this->add($email); $password = new Password('password', array('placeholder' => 'Password', 'class' => 'form-control')); $password->addValidator(new PresenceOf(array('message' => 'The password is required'))); $this->add($password); $remember = new Check('remember', array('value' => 'yes')); $remember->setLabel('Remember me'); $this->add($remember); $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); $this->add(new Submit('Sing in', array('class' => 'btn btn-lg btn-primary btn-block'))); }
public function initialize($entity = null, $options = null) { if (isset($options['edit']) && $options['edit']) { $id = new Hidden('id'); } else { $id = new Text('id'); } $this->add($id); $this->add(new Hidden('birth_date')); $this->add(new Select('gender', array(0 => 'Male', 1 => 'Female'))); //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-success'))); }
public function initialize() { //New password $passwordNew = new Password('password_new', array('placeholder' => 'New password', 'class' => 'form-control', 'autocomplete' => 'off')); $passwordNew->addValidators(array(new PresenceOf(array('message' => 'Password is required')), new StringLength(array('min' => 5, 'messageMinimum' => 'Password is too short. Minimum 5 characters')), new Confirmation(array('message' => 'Password doesn\'t match confirmation', 'with' => 'password_new_confirm')))); $this->add($passwordNew); //Confirm New Password $passwordNewConfirm = new Password('password_new_confirm', array('placeholder' => 'Confirm new password', 'class' => 'form-control', 'autocomplete' => 'off')); $passwordNewConfirm->addValidator(new PresenceOf(array('message' => 'The confirmation password is required'))); $this->add($passwordNewConfirm); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); //Submit $this->add(new Submit('change', ['class' => 'submit-button-login', 'value' => 'Sign in'])); }
public function initialize($entity = null, $options = null) { $name = new Text('name'); $name->setLabel('Имя'); $name->addValidators(array(new PresenceOf(array('message' => 'Поле Имя обязательно для заполнения')))); $this->add($name); //Email $email = new Text('email'); $email->setLabel('E-Mail'); $email->addValidators(array(new PresenceOf(array('message' => 'Адрес электронной почты обязателен')), new Email(array('message' => 'Не верный адрес электронной почты')))); $this->add($email); /* //Password $password = new Password('password'); $password->setLabel('Пароль'); $password->addValidators(array( new PresenceOf(array('message' => 'Поле пароль обязательно')), new StringLength(array('min' => 8, 'messageMinimum' => 'Пароль слишком короткий. Минимум 8 знаков')), new Confirmation(array('message' => 'Не совпадение в полях паролей', 'with' => 'confirmPassword')))); $this->add($password); //Confirm Password $confirmPassword = new Password('confirmPassword'); $confirmPassword->setLabel('Подтвердить пароль'); $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'Поле подтверждения пароля обязательно')))); $this->add($confirmPassword); */ //Remember $terms = new Check('terms', array('value' => 'yes', 'class' => 'checkbox')); $terms->setLabel('Вы согласны с условиями соглашения'); $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Условия соглашения должны быть приняты'))); $this->add($terms); //CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'сработала защита от CSRF'))); $this->add($csrf); //Sign Up $this->add(new Submit('Зарегистрироваться', array('class' => 'btn btn-success'))); }
public function initialize($entity = null) { // In edit page the id is hidden if (!is_null($entity)) { $this->add(new Hidden('id')); } $value = new Text('name', ['placeholder' => 'Name', 'required' => 'true', 'autofocus' => 'true']); $value->addValidators([new PresenceOf(['message' => 'Name is required.'])]); $this->add($value); $this->add(new Select('idVenueType', VenueType::find(), ['using' => ['id', 'name']])); $this->add(new TextArea('address', ['rows' => 10, 'cols' => 10, 'placeholder' => 'Address'])); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $this->add($csrf); //Submit $this->add(new Submit('save', ['value' => 'Save', 'class' => 'btn btn-sm btn-info'])); }
public function initialize() { //email $email = new Text('email', array('placeholder' => 'Email')); $email->addValidators(array(new PresenceOf(array('message' => 'Введите Ваш E-mail')))); $this->add($email); //password $password = new Password('password', array('placeholder' => 'Password')); $password->addValidators(array(new PresenceOf(array('message' => 'Введите пароль')))); $password->clear(); $this->add($password); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'))); $csrf->clear(); $this->add($csrf); $this->add(new Submit('go', array('class' => 'btn btn-success'))); }
public function initialize($entity = null) { // In edit page the id is hidden if (!is_null($entity)) { $this->add(new Hidden('id')); } $title = new Text('title', ['placeholder' => 'Title', 'required' => 'true', 'autofocus' => 'true']); $title->addValidators([new PresenceOf(['message' => 'Title is required.'])]); $this->add($title); $this->add(new Text('key', ['placeholder' => 'Key', 'required' => 'true'])); $this->add(new TextArea('content', ['rows' => 30, 'cols' => 10, 'placeholder' => 'Content'])); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed')))); $this->add($csrf); //Submit $this->add(new Submit('save', ['value' => 'Save', 'class' => 'btn btn-sm btn-info'])); }
public function initialize($entity = null) { // In edit page the id is hidden if (!is_null($entity)) { $this->add(new Hidden('id')); } //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' => 8)); $content->addValidator(new PresenceOf(array('message' => t('content is required.')))); $this->add($content); $this->add(new Hidden('idObject')); $this->add(new Hidden('object')); $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed')))); $this->add($csrf); //Submit $this->add(new Submit('postAnswer', ['value' => t('Post Your Answer'), 'class' => 'btn btn-sm btn-info'])); }
public function initialize($para, $analytic) { $trackingID = Settings::getAnalyticTrackingID(); $accountID = Settings::getAnalyticAccountID(); // CSRF $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed')))); $this->add($csrf); $this->add(new Submit('save', ['name' => 'save', 'value' => 'Save Changes', 'class' => 'btn btn-sm btn-info'])); $author = new Submit('author', ['name' => 'author', 'value' => 'Authorization', 'class' => 'btn btn-sm btn-info']); $author->setLabel("Authorization this feature with Google"); $this->add($author); $unauthor = new Submit('unauthor', ['name' => 'unauthor', 'value' => 'Clear Authorization', 'class' => 'btn btn-sm btn-warning']); $unauthor->setLabel("This feature had been actived. Clear authorization ?"); $this->add($unauthor); $accessCode = new Text('accessCode', ['placeholder' => t('Access Code'), 'class' => 'form-control', 'value' => '']); $accessCode->setLabel('Access Code'); $this->add($accessCode); $listView = $analytic->getListView(); $listViewDisplay = []; if ($listView['state']) { foreach ($listView['listView'] as $view) { $parse = parse_url($view['profileURL']); $listViewDisplay[$view['webPropertyId'] . "_._" . $view['accountID']] = $parse['host'] . " => " . $view['profileName']; } } $selectView = new Select("selectView", $listViewDisplay, ['class' => 'form-control', 'useEmpty' => true, 'emptyText' => 'Please, choose one...']); $selectView->setLabel('Select View '); $selectView->setDefault($trackingID . "_._" . $accountID); $this->add($selectView); $data = Settings::getListTopActivity(); $listTopActivity = []; $listDefaultActivity = []; foreach ($data as $activity) { $listTopActivity[$activity->code] = $activity->name; if ($activity->default == 1) { $listDefaultActivity[] = $activity->code; } } $topActivity = new Select("topActivity", $listTopActivity, ['name' => 'topActivity[]', 'class' => 'form-control', 'multiple' => 'multiple']); $topActivity->setLabel('Select 4 activity on top of dashboard'); $topActivity->setDefault($listDefaultActivity); $this->add($topActivity); }
public function initialize($entity, $options) { if ($this->getUserOption('confirmCurrent')) { $current = new Password('current-password'); $current->setLabel('Current password'); $this->add($current); } $password = new Password('password'); $password->setLabel('New password'); $password->addValidators([new PresenceOf(['message' => 'The password is required', 'cancelOnFail' => true]), new StringLength(array('min' => 8, 'messageMinimum' => 'Password is too short. Minimum 8 characters')), new Regex(['pattern' => '/^(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).*$/', 'message' => 'The password is not strong enough. It must contain both upper, lowercase characters and at least one digit']), new Confirmation(array('message' => 'The password does not match it\'s confirmation', 'with' => 'password-confirm'))]); $this->add($password); $confirm = new Password('password-confirm'); $confirm->setLabel('Confirm new password'); $confirm->addValidators([new PresenceOf(['message' => 'The password confirmation is required'])]); $this->add($confirm); $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(['value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed'])); $this->add($csrf); }
public function initialize() { //Phalcon\Forms\Element //public __construct (string $name, [array $attributes]) $email = new Text('email', array('placeholder' => 'Email')); $email->addValidators(array(new PresenceOf(array('message' => 'The email is required')), new Email(array('message' => 'The email is not valid')))); $this->add($email); $password = new Password('password', array('placeholder' => 'Password')); $password->addValidator(new PresenceOf(array('message' => 'The password is required'))); $this->add($password); $remember = new Check('remember', array('value' => 'yes')); $remember->setLabel('Remember me'); $this->add($remember); //Cross-Site Request Forgery $csrf = new Hidden('csrf'); $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CsrF validation failed'))); $this->add($csrf); $this->add(new Submit('signin', array('class' => 'btn btn-lg btn-primary btn-block'))); }