public function initialize() { $this->_action = 'menuitem_add'; $name = new Text('name'); $name->setFilters(array('striptags', 'string')); $name->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off', 'id' => 'menuitem_name')); $name->setLabel('Name'); $url = new Text('url'); $url->setFilters(array('striptags', 'string')); $url->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off')); $url->setLabel('URL'); $icon = new Text('icon'); $icon->setFilters(array('striptags', 'string')); $icon->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off')); $icon->setLabel('Icon'); $device = new Select('device_id', Devices::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => 'None', 'emptyValue' => 0)); $device->setLabel('Device'); $menuId = new Hidden('menu_id'); $menuId->setDefault(1); $this->add($name); $this->add($url); $this->add($icon); $this->add($device); $this->add($menuId); }
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'))); }
function initialize($entity = null, $options = null) { $date = new Date('date'); $date->setLabel('Input Date'); $date->setFilters(array('striptags', 'string')); $date->setDefault(date('Y-m-d')); $date->addValidators(array(new PresenceOf(array('message' => 'Date is required')))); $this->add($date); $start_time = new Text('start_hour'); $start_time->setLabel('Input Start Hour'); $start_time->setFilters(array('striptags', 'string')); $start_time->addValidators(array(new PresenceOf(array('message' => 'Start Time is required')))); $this->add($start_time); $finish_time = new Text('finish_hour'); $finish_time->setLabel('Input Finish Hour'); $finish_time->setFilters(array('striptags', 'string')); $finish_time->addValidators(array(new PresenceOf(array('message' => 'Finish Time is required')))); $this->add($finish_time); $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $systemId->setLabel('Select System'); $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required')))); if ($entity) { $systemId->setDefault(array($entity->system_id)); } $this->add($systemId); $description = new TextArea('description'); $description->setLabel('Input Description'); $description->addValidators(array(new PresenceOf(array('message' => 'Description is required')))); $this->add($description); $hidden = new Hidden('id'); if ($entity) { $hidden->setDefault(array($entity->id)); } $this->add($hidden); }
public function initialize($menuitems) { $this->_action = 'menu'; foreach ($menuitems as $menuItem) { $name = new Text('menuitem[' . $menuItem->id . '][name]'); $name->setFilters(array('striptags', 'string')); $name->setAttributes(array('class' => 'form-control')); $name->setDefault($menuItem->name); $url = new Text('menuitem[' . $menuItem->id . '][url]'); $url->setFilters(array('striptags', 'string')); $url->setAttributes(array('class' => 'form-control')); $url->setDefault($menuItem->url); $icon = new Text('menuitem[' . $menuItem->id . '][icon]'); $icon->setFilters(array('striptags', 'string')); $icon->setAttributes(array('class' => 'form-control')); $icon->setDefault($menuItem->icon); $device = new Select('menuitem[' . $menuItem->id . '][device]', Devices::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => 'None', 'emptyValue' => 0)); $device->setDefault($menuItem->device_id); $id = new Hidden('menuitem[' . $menuItem->id . '][id]'); $id->setDefault($menuItem->id); $this->add($name); $this->add($url); $this->add($icon); $this->add($device); $this->add($id); } }
public function initialize($entity = null, $options = null) { parent::initialize(); // In edition the id is hidden if (isset($options['edit']) && $options['edit']) { $id = new Hidden('id'); $id->addValidators(array(new PresenceOf(array('message' => 'ID missing')))); $this->add($id); } else { // Password $password = new Password('password', array('placeholder' => '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')))); $this->add($password); } $name = new Text('name', array('placeholder' => 'Name')); $name->setLabel('Name'); $name->addValidators(array(new PresenceOf(array('message' => 'The name is required')))); $this->add($name); $email = new Text('email', array('placeholder' => 'Email')); $email->setLabel('Email'); $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); $this->add(new Select('validated', array('1' => 'Yes', '0' => 'No'))); $this->add(new Select('active', array('1' => 'Yes', '0' => 'No'))); $this->add(new Submit('Save')); }
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) { $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($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() { //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() { $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, $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($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($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() { $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() { $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() { $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($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() { // 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() { //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($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 setMethod($method) { $method = strtoupper($method); if ($this->has(self::_METHOD)) { $this->get(self::_METHOD)->setAttribute('value', $method); } else { $element = new Hidden(self::_METHOD); $element->setAttribute('value', $method); $this->add($element); } $this->setAttribute('data-method', $method); if ($this->isValidMethod($method)) { $this->_method = $method; } return $this; }
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'])); }
function initialize($entity = null, $options = null) { $date = new Date('date_found'); $date->setLabel('Input Date Found'); $date->setFilters(array('striptags', 'string')); $this->add($date); /*====================== Number =====================*/ $number = new Text('number'); $number->setLabel('Input Number'); $number->setFilters(array('striptags', 'string')); $number->addValidators(array(new PresenceOf(array('message' => 'Number is required')))); $this->add($number); /*====================== Solved =====================*/ $isSolved = new Radio('is_solved', array('name' => 'is_solved', 'value' => '1')); $isSolved->setLabel('Is Solved'); $isSolved->addValidators(array(new PresenceOf(array('message' => 'Is solved is required')))); $this->add($isSolved); $isSolved2 = new Radio('is_solved2', array('name' => 'is_solved', 'value' => '0', 'checked' => TRUE)); $isSolved2->setLabel('Is Solved2'); $isSolved2->addValidators(array(new PresenceOf(array('message' => 'Is solved is required')))); $this->add($isSolved2); $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $systemId->setLabel('Select System'); $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required')))); if ($entity) { $systemId->setDefault(array($entity->system_id)); } $this->add($systemId); $modulesId = new Select('modules_id', Modules::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $modulesId->setLabel('Select Modules'); $modulesId->addValidators(array(new PresenceOf(array('message' => 'Modules is required')))); if ($entity) { $modulesId->setDefault(array($entity->modules_id)); } $this->add($modulesId); /*===== Bug =============*/ $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $systemId->setLabel('Select System'); $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required')))); if ($entity) { $systemId->setDefault(array($entity->system_id)); } $this->add($systemId); $description = new TextArea('description'); $description->setLabel('Input Description'); $description->addValidators(array(new PresenceOf(array('message' => 'Description is required')))); $this->add($description); $hidden = new Hidden('id'); if ($entity) { $hidden->setDefault(array($entity->id)); } $this->add($hidden); }