本文整理汇总了PHP中Form::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getValues方法的具体用法?PHP Form::getValues怎么用?PHP Form::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$language = OW::getLanguage();
$billingService = BOL_BillingService::getInstance();
$adminForm = new Form('adminForm');
$element = new TextField('creditValue');
$element->setRequired(true);
$element->setLabel($language->text('billingcredits', 'admin_usd_credit_value'));
$element->setDescription($language->text('billingcredits', 'admin_usd_credit_value_desc'));
$element->setValue($billingService->getGatewayConfigValue('billingcredits', 'creditValue'));
$validator = new FloatValidator(0.1);
$validator->setErrorMessage($language->text('billingcredits', 'invalid_numeric_format'));
$element->addValidator($validator);
$adminForm->addElement($element);
$element = new Submit('saveSettings');
$element->setValue($language->text('billingcredits', 'admin_save_settings'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$billingService->setGatewayConfigValue('billingcredits', 'creditValue', $values['creditValue']);
OW::getFeedback()->info($language->text('billingcredits', 'user_save_success'));
}
}
$this->addForm($adminForm);
$this->setPageHeading(OW::getLanguage()->text('billingcredits', 'config_page_heading'));
$this->setPageTitle(OW::getLanguage()->text('billingcredits', 'config_page_heading'));
$this->setPageHeadingIconClass('ow_ic_app');
}
示例2: testAddControl
/**
* @covers Form::addControl
*/
public function testAddControl()
{
$this->myForm->setValue('verify', 'required');
$this->myForm->addControl('verify', new \Textbox('phone'));
$this->assertArrayHasKey('verify', $this->myForm->getControls());
$this->assertArrayHasKey('verify', $this->myForm->getValues());
}
示例3: action
/**
* The action that displays the entry insert form .
*
* @param PDO $pdo The PDO object.
* @return Opt_View
*/
function action($pdo, $config)
{
$view = new Opt_View('add.tpl');
$view->title = 'Add new entry';
$form = new Form($view);
$form->setAction('index.php?action=add');
$form->addField('author', 'required,min_len=3,max_len=30', 'The length must be between 3 and 30 characters.');
$form->addField('email', 'required,email,min_len=3,max_len=100', 'The value must be a valid mail with maximum 100 characters long.');
$form->addField('website', 'url,min_len=3,max_len=100', 'The value must be a valid URL with maximum 100 characters long.');
$form->addField('body', 'required,min_len=3', 'The body must be at least 3 characters long.');
if ($form->validate()) {
$values = $form->getValues();
$stmt = $pdo->prepare('INSERT INTO `entries` (`author`, `email`, `date`, `website`, `body`)
VALUES(:author, :email, :date, :website, :body)');
$stmt->bindValue(':author', $values['author'], PDO::PARAM_STR);
$stmt->bindValue(':email', $values['email'], PDO::PARAM_STR);
$stmt->bindValue(':date', time(), PDO::PARAM_INT);
$stmt->bindValue(':website', $values['website'], PDO::PARAM_STR);
$stmt->bindValue(':body', $values['body'], PDO::PARAM_STR);
$stmt->execute();
$view->setTemplate('message.tpl');
$view->message = 'The entry has been successfully added!';
$view->redirect = 'index.php?action=list';
} else {
// The form is an object, so we need to inform OPT about it.
$view->form = $form;
$view->setFormat('form', 'Objective');
}
return $view;
}
示例4: settings
public function settings()
{
$adminForm = new Form('adminForm');
$language = OW::getLanguage();
$config = OW::getConfig();
$element = new TextField('autoclick');
$element->setRequired(true);
$validator = new IntValidator(1);
$validator->setErrorMessage($language->text('autoviewmore', 'admin_invalid_number_error'));
$element->addValidator($validator);
$element->setLabel($language->text('autoviewmore', 'admin_auto_click'));
$element->setValue($config->getValue('autoviewmore', 'autoclick'));
$adminForm->addElement($element);
$element = new Submit('saveSettings');
$element->setValue($language->text('autoviewmore', 'admin_save_settings'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$config = OW::getConfig();
$config->saveConfig('autoviewmore', 'autoclick', $values['autoclick']);
OW::getFeedback()->info($language->text('autoviewmore', 'user_save_success'));
}
}
$this->addForm($adminForm);
}
示例5: testShouldSetNameToCategory
function testShouldSetNameToCategory()
{
$form = new Form(null);
$this->assertTrue($form->isValid(['name' => 'wheels']));
$category = $form->getValues();
$this->assertEquals('wheels', $category['name'], 'should copy name from form to category');
}
示例6: __construct
public function __construct()
{
parent::__construct();
$language = OW::getLanguage();
$form = new Form("change-user-password");
$form->setId("change-user-password");
$oldPassword = new PasswordField('oldPassword');
$oldPassword->setLabel($language->text('base', 'change_password_old_password'));
$oldPassword->addValidator(new OldPasswordValidator());
$oldPassword->setRequired();
$form->addElement($oldPassword);
$newPassword = new PasswordField('password');
$newPassword->setLabel($language->text('base', 'change_password_new_password'));
$newPassword->setRequired();
$newPassword->addValidator(new NewPasswordValidator());
$form->addElement($newPassword);
$repeatPassword = new PasswordField('repeatPassword');
$repeatPassword->setLabel($language->text('base', 'change_password_repeat_password'));
$repeatPassword->setRequired();
$form->addElement($repeatPassword);
$submit = new Submit("change");
$submit->setLabel($language->text('base', 'change_password_submit'));
$form->setAjax(true);
$form->addElement($submit);
if (OW::getRequest()->isAjax()) {
$result = false;
if ($form->isValid($_POST)) {
$data = $form->getValues();
BOL_UserService::getInstance()->updatePassword(OW::getUser()->getId(), $data['password']);
$result = true;
}
echo json_encode(array('result' => $result));
exit;
} else {
$messageError = $language->text('base', 'change_password_error');
$messageSuccess = $language->text('base', 'change_password_success');
$js = " owForms['" . $form->getName() . "'].bind( 'success',\n function( json )\n {\n \tif( json.result == true )\n \t{\n \t \$('#TB_closeWindowButton').click();\n \t OW.info('{$messageSuccess}');\n }\n else\n {\n OW.error('{$messageError}');\n }\n\n } ); ";
OW::getDocument()->addOnloadScript($js);
$this->addForm($form);
$language->addKeyForJs('base', 'join_error_password_not_valid');
$language->addKeyForJs('base', 'join_error_password_too_short');
$language->addKeyForJs('base', 'join_error_password_too_long');
//include js
$onLoadJs = " window.changePassword = new OW_BaseFieldValidators( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Join", "ajaxResponder"), 'passwordMaxLength' => UTIL_Validator::PASSWORD_MAX_LENGTH, 'passwordMinLength' => UTIL_Validator::PASSWORD_MIN_LENGTH)) . ",\n " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . " ); ";
$onLoadJs .= " window.oldPassword = new OW_ChangePassword( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . " ); ";
OW::getDocument()->addOnloadScript($onLoadJs);
$jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
OW::getDocument()->addScript($jsDir . "base_field_validators.js");
OW::getDocument()->addScript($jsDir . "change_password.js");
}
}
示例7: exampleForm
private function exampleForm()
{
$countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
$sex = array('m' => 'male', 'f' => 'female');
// Step 1: Define form with validation rules
$form = new Form();
// group Personal data
$form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
$form->addText('name', 'Your name:', 35)->addRule(Form::FILLED, 'Enter your name');
$form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100));
$form->addRadioList('gender', 'Your gender:', $sex);
$form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
// ... then check email
// group Shipping address
$form->addGroup('Shipping address')->setOption('embedNext', TRUE);
$form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox');
// toggle div #sendBox
// subgroup
$form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
$form->addText('street', 'Street:', 35);
$form->addText('city', 'City:', 35)->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address');
$form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country');
// group Your account
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password:', 20)->addRule(Form::FILLED, 'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);
$form->addPassword('password2', 'Reenter password:', 20)->addConditionOn($form['password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
$form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*');
$form->addHidden('userid');
$form->addTextArea('note', 'Comment:', 30, 5);
// group for buttons
$form->addGroup();
$form->addSubmit('submit1', 'Send');
// Step 2: Check if form was submitted?
if ($form->isSubmitted()) {
// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>Form was submitted and successfully validated</h2>';
$values = $form->getValues();
Debug::dump($values);
// this is the end, my friend :-)
if (empty($disableExit)) {
exit;
}
}
} else {
// not submitted, define default values
$defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ');
$form->setDefaults($defaults);
}
return $form;
}
示例8: onSettingsFormSubmit
public function onSettingsFormSubmit(Form $form)
{
if (!$form->isValid()) {
return;
}
$content = "<?php\nreturn " . var_export($form->getValues(), TRUE) . ";\n";
if (!@file_put_contents(Environment::expand('safe://%settingsFile%'), $content)) {
$form->addError(__('Cannot write settings.'));
return;
}
adminlog::log(__('Updated settings'));
$this->redirect('this');
$this->terminate();
}
示例9: FormSubmitted
function FormSubmitted(Form $form)
{
$formular = $this->form->getValues();
try {
// Ověření přihlašovacích údajů uživatele
$this->user->login($formular['userName'], hash(HASH_TYPE, $formular['password']));
// předáme přihlašovací jméno a heslo
/*
* Doba odhlášení nastavena na 120 minut
* Uživatel bude odhlášen při zavření prohlížeče
* Při odhlášení uživatele bude smazána identita
*/
$this->user->setExpiration(120 * 60, TRUE, TRUE);
} catch (Exception $e) {
$this->flashMessage('Bylo zadáno špatné uživatelské jméno nebo heslo.');
}
if ($this->user->isLoggedIn()) {
$this->flashMessage('Přihlášení proběhlo úspěšně.');
if (!empty($this->backlink)) {
$this->getApplication()->restoreRequest($this->backlink);
}
$this->redirect('Default:');
}
}
示例10: onLoginFormSubmit
public function onLoginFormSubmit(Form $form)
{
$user = Environment::getUser();
$user->setAuthenticationHandler(new SimpleAuthenticator(array(ADMIN_USERNAME => ADMIN_PASSWORD)));
$values = $form->getValues();
try {
$user->authenticate($values['username'], $values['password']);
adminlog::log(__('Successfully logged in as "%s"'), Environment::getUser()->getIdentity()->getName());
$this->redirect('Dashboard:default');
$this->terminate();
} catch (AuthenticationException $e) {
adminlog::log(__('Unsuccessful log in (username: "%s", password: "%s")'), $values['username'], $values['password']);
$this->template->error = $e;
}
}
示例11: fillAccountType
public function fillAccountType($params)
{
if (!OW::getUser()->isAuthenticated()) {
throw new AuthenticateException();
}
$user = OW::getUser()->getUserObject();
$accountType = BOL_QuestionService::getInstance()->findAccountTypeByName($user->accountType);
if (!empty($accountType)) {
throw new Redirect404Exception();
}
$event = new OW_Event(OW_EventManager::ON_BEFORE_USER_COMPLETE_ACCOUNT_TYPE, array('user' => $user));
OW::getEventManager()->trigger($event);
$accounts = $this->getAccountTypes();
if (count($accounts) == 1) {
$accountTypeList = array_keys($accounts);
$firstAccountType = reset($accountTypeList);
$accountType = BOL_QuestionService::getInstance()->findAccountTypeByName($firstAccountType);
if ($accountType) {
$user->accountType = $firstAccountType;
BOL_UserService::getInstance()->saveOrUpdate($user);
//BOL_PreferenceService::getInstance()->savePreferenceValue('profile_details_update_stamp', time(), $user->getId());
$this->redirect(OW::getRouter()->urlForRoute('base_default_index'));
}
}
$form = new Form('accountTypeForm');
$joinAccountType = new Selectbox('accountType');
$joinAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
$joinAccountType->setRequired();
$joinAccountType->setOptions($accounts);
$joinAccountType->setHasInvitation(false);
$form->addElement($joinAccountType);
$submit = new Submit('submit');
$submit->addAttribute('class', 'ow_button ow_ic_save');
$submit->setValue(OW::getLanguage()->text('base', 'continue_button'));
$form->addElement($submit);
if (OW::getRequest()->isPost()) {
if ($form->isValid($_POST)) {
$data = $form->getValues();
$this->saveRequiredQuestionsData($data, $user->id);
}
} else {
OW::getDocument()->addOnloadScript(" OW.info(" . json_encode(OW::getLanguage()->text('base', 'complete_profile_info')) . ") ");
}
$this->addForm($form);
}
示例12: index
public function index()
{
$language = OW::getLanguage();
$config = OW::getConfig();
$adminForm = new Form('adminForm');
$element = new Selectbox('actionMember');
$element->setLabel($language->text('grouprss', 'action_member_label'));
$element->setDescription($language->text('grouprss', 'action_member_desc'));
$element->setValue($config->getValue('grouprss', 'actionMember'));
$element->setRequired();
$element->addOption('admin', $language->text('grouprss', 'site_admin'));
$element->addOption('owner', $language->text('grouprss', 'group_owner'));
$element->addOption('both', $language->text('grouprss', 'both_admin_owner'));
$adminForm->addElement($element);
$element = new Selectbox('postLocation');
$element->setLabel($language->text('grouprss', 'post_location_label'));
$element->setDescription($language->text('grouprss', 'post_location_desc'));
$element->setValue($config->getValue('grouprss', 'postLocation'));
$element->setRequired();
$element->addOption('wall', $language->text('grouprss', 'wall_location'));
$element->addOption('newsfeed', $language->text('grouprss', 'newsfeed_location'));
$adminForm->addElement($element);
$element = new CheckboxField('disablePosting');
$element->setLabel($language->text('grouprss', 'disable_posting_label'));
$element->setDescription($language->text('grouprss', 'disable_posting_desc'));
$element->setValue($config->getValue('grouprss', 'disablePosting'));
$adminForm->addElement($element);
$element = new Submit('saveSettings');
$element->setValue(OW::getLanguage()->text('grouprss', 'admin_save_settings'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$config->saveConfig('grouprss', 'actionMember', $values['actionMember']);
$config->saveConfig('grouprss', 'postLocation', $values['postLocation']);
$config->saveConfig('grouprss', 'disablePosting', $values['disablePosting']);
GROUPRSS_BOL_FeedService::getInstance()->addAllGroupFeed();
//OW::getFeedback()->info($language->text('grouprss', 'user_save_success'));
}
}
$this->addForm($adminForm);
}
示例13: index
public function index()
{
$language = OW::getLanguage();
$config = OW::getConfig();
$adminForm = new Form('adminForm');
$element = new TextField('logsPerPage');
$element->setRequired(true);
$element->setValue($config->getValue('credits', 'logsPerPage'));
$element->setLabel($language->text('credits', 'logs_per_page'));
$element->addValidator(new IntValidator(1));
$adminForm->addElement($element);
$element = new CheckboxField('enableEmail');
$element->setLabel(OW::getLanguage()->text('credits', 'admin_enable_email'));
$element->setDescription(OW::getLanguage()->text('credits', 'admin_enable_email_desc'));
$element->setValue($config->getValue('credits', 'enableEmail'));
$adminForm->addElement($element);
$element = new CheckboxField('enablePM');
$element->setLabel(OW::getLanguage()->text('credits', 'admin_enable_pm'));
$element->setDescription(OW::getLanguage()->text('credits', 'admin_enable_pm_desc'));
$element->setValue($config->getValue('credits', 'enablePM'));
$adminForm->addElement($element);
$element = new CheckboxField('enableNotification');
$element->setLabel(OW::getLanguage()->text('credits', 'admin_enable_notification'));
$element->setDescription(OW::getLanguage()->text('credits', 'admin_enable_notification_desc'));
$element->setValue($config->getValue('credits', 'enableNotification'));
$adminForm->addElement($element);
$element = new Submit('saveSettings');
$element->setValue(OW::getLanguage()->text('credits', 'admin_save_settings'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$config->saveConfig('credits', 'logsPerPage', $values['logsPerPage']);
$config->saveConfig('credits', 'enableEmail', $values['enableEmail']);
$config->saveConfig('credits', 'enablePM', $values['enablePM']);
$config->saveConfig('credits', 'enableNotification', $values['enableNotification']);
OW::getFeedback()->info($language->text('credits', 'save_sucess_msg'));
}
}
$this->addForm($adminForm);
}
示例14: index
public function index()
{
$this->setPageHeading(OW::getLanguage()->text('ganalytics', 'admin_index_heading'));
$this->setPageHeadingIconClass('ow_ic_gear_wheel');
$form = new Form('ganalytics_web_id');
$element = new TextField('web_property_id');
$form->addElement($element);
$submit = new Submit('submit');
$submit->setValue(OW::getLanguage()->text('admin', 'save_btn_label'));
$form->addElement($submit);
if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
$data = $form->getValues();
if (!empty($data['web_property_id']) && strlen(trim($data['web_property_id'])) > 0) {
OW::getConfig()->saveConfig('ganalytics', 'web_property_id', trim($data['web_property_id']));
OW::getFeedback()->info(OW::getLanguage()->text('ganalytics', 'admin_index_property_id_save_success_message'));
} else {
OW::getFeedback()->error(OW::getLanguage()->text('ganalytics', 'admin_index_property_id_save_error_message'));
}
$this->redirect();
}
$element->setValue(OW::getConfig()->getValue('ganalytics', 'web_property_id'));
$this->addForm($form);
}
示例15: categories
public function categories()
{
$adminForm = new Form('categoriesForm');
$language = OW::getLanguage();
$element = new TextField('categoryName');
$element->setRequired();
$element->setInvitation($language->text('advancedphoto', 'admin_category_name'));
$element->setHasInvitation(true);
$adminForm->addElement($element);
$element = new Submit('addCategory');
$element->setValue($language->text('advancedphoto', 'admin_add_category'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$name = ucwords(strtolower($values['categoryName']));
$desc = ucwords(strtolower($values['categoryDesc']));
if (ADVANCEDPHOTO_BOL_CategoryService::getInstance()->addCategory($name, $desc)) {
OW::getFeedback()->info($language->text('advancedphoto', 'admin_add_category_success'));
} else {
OW::getFeedback()->error($language->text('advancedphoto', 'admin_add_category_error'));
}
$this->redirect();
}
}
$this->addForm($adminForm);
$allCategories = array();
$deleteUrls = array();
$categories = ADVANCEDPHOTO_BOL_CategoryService::getInstance()->getCategoriesList();
foreach ($categories as $category) {
$allCategories[$category->id]['id'] = $category->id;
$allCategories[$category->id]['name'] = $category->name;
$deleteUrls[$category->id] = OW::getRouter()->urlFor(__CLASS__, 'delete', array('id' => $category->id));
}
$this->assign('allCategories', $allCategories);
$this->assign('deleteUrls', $deleteUrls);
}