当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::isSubmitted方法代码示例

本文整理汇总了PHP中Form::isSubmitted方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::isSubmitted方法的具体用法?PHP Form::isSubmitted怎么用?PHP Form::isSubmitted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Form的用法示例。


在下文中一共展示了Form::isSubmitted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 /**
  * @abstract Displays and processes the edit news form
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     if (!files()->setUploadDirectory()) {
         sml()->say("The file upload directory does not appear to be writable. Please create the folder and set proper permissions.");
     }
     $form = new Form('news', $id);
     if (!$id) {
         $form->setCurrentValue('timestamp', date("Y-m-d H:i:s"));
     }
     // if form has been submitted
     if ($form->isSubmitted()) {
         $file = files()->upload('pdf_filename');
         if (is_array($file) && !empty($file[0])) {
             $form->setCurrentValue('pdf_filename', $file[0]['file_name']);
         }
         if ($form->save($id)) {
             sml()->say('News entry has successfully been updated.');
             router()->redirect('view');
         }
     }
     // make sure the template has access to all current values
     $data['form'] = $form;
     template()->addCss('admin/datepicker.css');
     template()->addJs('admin/datepicker.js');
     template()->addJs('edit.js');
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:32,代码来源:News_Admin.php

示例2: view

 /**
  * Loads our index/default welcome/dashboard screen
  */
 public function view()
 {
     $form = new Form('config');
     // add all config variables to our form
     $sql = sprintf('SELECT * FROM config');
     $model = model()->open('config');
     $records = $model->results();
     if ($records) {
         foreach ($records as $record) {
             $value = $record['current_value'] == '' ? $record['default_value'] : $record['current_value'];
             $form->addField($record['config_key'], $value, $value);
         }
     }
     // process the form if submitted
     if ($form->isSubmitted()) {
         foreach (app()->params->getRawSource('post') as $field => $value) {
             $model->update(array('current_value' => $value), $field, 'config_key');
         }
         sml()->say('Website settings have been updated successfully.');
         router()->redirect('view');
     }
     $data['form'] = $form;
     $model = model()->open('pages');
     $model->where('page_is_live', 1);
     $data['pages'] = $model->results();
     //		$data['mods'] = app()->moduleControls();
     $data['themes'] = $this->listThemes();
     $data['live'] = settings()->getConfig('active_theme');
     template()->addCss('style.css');
     template()->addJs('admin/jquery.qtip.js');
     template()->addJs('view.js');
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:36,代码来源:Admin_Admin.php

示例3: getRegisterForm

 public function getRegisterForm($target = '/Vote/register')
 {
     $form = new Form('group_register', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('text', 'first_name', 'First Name');
     $form->addElement('text', 'last_name', 'Last Name');
     $form->addElement('text', 'company', 'Company/Group');
     $form->addElement('text', 'email', 'E-mail');
     $form->addElement('text', 'phone', 'Work Phone');
     $form->addElement('text', 'cell_phone', 'Cell Phone');
     $form->addElement('submit', 'register_submit', 'Submit');
     $form->addRule('first_name', 'Please enter your first name', 'required');
     $form->addRule('last_name', 'Please enter your last name', 'required');
     $form->addRule('company', 'Please enter your company/group', 'required');
     $form->addRule('email', 'Please enter your e-mail address', 'required');
     $form->addRule('email', 'Please enter a valid email address', 'email');
     $form->addRule('phone', 'Please enter your phone number', 'required');
     if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['register_submit'])) {
         $body = "New registration request: \n\n";
         $body .= "Name: " . $form->exportValue('last_name') . ', ' . $form->exportValue('first_name');
         $body .= "\nCompany/Group: " . $form->exportValue('company');
         $body .= "\nE-mail address: " . $form->exportValue('email');
         $body .= "\nPhone number(s): Work - " . $form->exportValue('phone') . ', Cell - ' . $form->exportValue('cell_phone');
         $body .= "\n\nRequest sent on " . date("w F jS \\a\\t g:ia");
         mail('register@safeballot.com', 'Safeballot: New Request', $body, 'From: no-reply@safeballot.com');
     }
     return $form;
 }
开发者ID:swat30,项目名称:safeballot,代码行数:27,代码来源:CampaignRegister.php

示例4: edit

 /**
  * @abstract Displays and processes the edit news form
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     $form = new Form('forms', $id);
     if ($form->isSubmitted()) {
         if ($form->save($id)) {
             sml()->say('Form has been updated successfully.');
             router()->redirect('view');
         }
     }
     $data['form'] = $form;
     template()->addJs('edit.js');
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:18,代码来源:Forms_Admin.php

示例5: 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;
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:51,代码来源:Exec.php

示例6: edit

 /**
  * @abstract Edits an event recprd
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     $form = new Form('courses', $id);
     // grab existing groups settings
     $model = model()->open('course_groups_link');
     $model->where('course_id', $id);
     $group_records = $model->results();
     $groups = array();
     if ($group_records) {
         foreach ($group_records as $course_record) {
             $groups[] = $course_record['group_id'];
         }
     }
     $form->addField('groups', $groups, $groups);
     // proces the form if submitted
     if ($form->isSubmitted()) {
         // validation
         if (!$form->isFilled('title')) {
             $form->addError('title', 'You must enter a course title.');
         }
         // if we have no errors, process sql
         if (!$form->error()) {
             if ($res_id = $form->save($id)) {
                 $id = $id ? $id : $res_id;
                 // update course groups
                 $model->delete('course_groups_link', $id, 'course_id');
                 $groups = $form->cv('groups');
                 foreach ($groups as $group) {
                     $sql = sprintf('INSERT INTO course_groups_link (course_id, group_id) VALUES ("%s", "%s")', $id, $group);
                     $model->query($sql);
                 }
                 // if successful insert, redirect to the list
                 sml()->say('The course has successfully been saved.');
                 router()->redirect('view');
             }
         }
     }
     $data['form'] = $form;
     template()->addView(template()->getTemplateDir() . DS . 'header.tpl.php');
     template()->addView(template()->getModuleTemplateDir() . DS . 'edit.tpl.php');
     template()->addView(template()->getTemplateDir() . DS . 'footer.tpl.php');
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:48,代码来源:Courses_Admin.php

示例7: add

 /**
  * @abstract Add a new page
  * @access public
  */
 public function add()
 {
     $form = new Form('pages');
     // process the form if submitted
     if ($form->isSubmitted()) {
         $form->setCurrentValue('page_sort_order', $model->quickValue('SELECT MAX(page_sort_order) FROM pages', 'MAX(page_sort_order)') + 1);
         // form field validation
         if (!$form->isFilled('page_title')) {
             $form->addError('page_title', 'You must enter a page title.');
         }
         // if we have no errors, save the record
         if (!$form->error()) {
             // set the link text field to the page title if blank
             if (!$form->isFilled('page_link_text')) {
                 $form->setCurrentValue('page_link_text', $form->cv('page_title'));
             }
             return $form->save();
         }
     }
     return false;
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:25,代码来源:Pages_lib.php

示例8: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartTaxRate_addedit', 'post', $target);
     $form->setConstants(array('section' => 'tax_rates'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('carttaxrate_tax_rates_id' => $this->getId()));
         $form->addElement('hidden', 'carttaxrate_tax_rates_id');
         $defaultValues['carttaxrate_zone'] = $this->getZone();
         $defaultValues['carttaxrate_taxClass'] = $this->getTaxClass()->getId();
         //$defaultValues ['carttaxrate_tax_priority'] = $this->getTax_priority();
         $defaultValues['carttaxrate_rate'] = $this->getRate();
         $defaultValues['carttaxrate_description'] = $this->getDescription();
         //$defaultValues ['carttaxrate_last_modified'] = $this->getLast_modified();
         //$defaultValues ['carttaxrate_date_added'] = $this->getDate_added();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('select', 'carttaxrate_zone', 'Zone', Form::getStatesArray());
     $form->addElement('select', 'carttaxrate_taxClass', 'Tax Class', CartTaxClass::toArray());
     //$form->addElement('text', 'carttaxrate_tax_priority', 'tax_priority');
     $form->addElement('text', 'carttaxrate_rate', 'Tax Rate (%)');
     $form->addElement('text', 'carttaxrate_description', 'Description');
     //$form->addElement('text', 'carttaxrate_last_modified', 'last_modified');
     //$form->addElement('text', 'carttaxrate_date_added', 'date_added');
     $form->addElement('submit', 'carttaxrate_submit', 'Submit');
     $form->addRule('carttaxrate_rate', 'Please enter a Tax Rate', 'required', null);
     $form->addRule('carttaxrate_description', 'Please enter a Description', 'required', null);
     if ($form->validate() && $form->isSubmitted()) {
         $this->setZone($form->exportValue('carttaxrate_zone'));
         $this->setTaxClass($form->exportValue('carttaxrate_taxClass'));
         //$this->setTax_priority($form->exportValue('carttaxrate_tax_priority'));
         $this->setRate($form->exportValue('carttaxrate_rate'));
         $this->setDescription($form->exportValue('carttaxrate_description'));
         //$this->setLast_modified($form->exportValue('carttaxrate_last_modified'));
         //$this->setDate_added($form->exportValue('carttaxrate_date_added'));
         $this->save();
     }
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:46,代码来源:CartTaxRate.php

示例9: getCSVForm

 public static function getCSVForm($target = '/admin/Campaigns&section=recipcsvup')
 {
     $form = new Form('csv_add', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('file', 'csv_file', 'CSV File');
     $form->addElement('submit', 'submit', 'Upload');
     $form->addRule('csv_file', 'Please upload a csv file', 'uploaded');
     if ($form->validate() && $form->isSubmitted() && $_POST['submit']) {
         Campaign::parseCsv($_FILES['csv_file']['tmp_name']);
     }
     return $form;
 }
开发者ID:swat30,项目名称:safeballot,代码行数:11,代码来源:Campaign.php

示例10: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     //Only the name will be displayed to the administrator
     //All the other attributes are not valid for feedstore.ca
     $form = new Form('CartProductType_addedit', 'post', $target);
     $form->setConstants(array('section' => 'product_types'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartproducttype_type_id' => $this->getId()));
         $form->addElement('hidden', 'cartproducttype_type_id');
         $defaultValues['cartproducttype_name'] = $this->getName();
         /*
         $defaultValues ['cartproducttype_handler'] = $this->getHandler();
         $defaultValues ['cartproducttype_masterType'] = $this->getMasterType();
         $defaultValues ['cartproducttype_allow_add_to_cart'] = $this->getAllow_add_to_cart();
         $defaultValues ['cartproducttype_image'] = $this->getImage()->getId();
         $defaultValues ['cartproducttype_date_added'] = $this->getDate_added();
         $defaultValues ['cartproducttype_last_modified'] = $this->getLast_modified();
         */
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartproducttype_name', 'name');
     /*
     $form->addElement('text', 'cartproducttype_handler', 'handler');
     $form->addElement('text', 'cartproducttype_masterType', 'masterType');
     $form->addElement('text', 'cartproducttype_allow_add_to_cart', 'allow_add_to_cart');
     $form->addElement('text', 'cartproducttype_image', 'image');
     $form->addElement('text', 'cartproducttype_date_added', 'date_added');
     $form->addElement('text', 'cartproducttype_last_modified', 'last_modified');
     */
     $form->addElement('submit', 'cartproducttype_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setName($form->exportValue('cartproducttype_name'));
         /*
         $this->setHandler($form->exportValue('cartproducttype_handler'));
         $this->setMasterType($form->exportValue('cartproducttype_masterType'));
         $this->setAllow_add_to_cart($form->exportValue('cartproducttype_allow_add_to_cart'));
         $this->setImage($form->exportValue('cartproducttype_image'));
         $this->setDate_added($form->exportValue('cartproducttype_date_added'));
         $this->setLast_modified($form->exportValue('cartproducttype_last_modified'));
         */
         $this->save();
     }
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:52,代码来源:CartProductType.php

示例11: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartShippingRate_addedit', 'post', $target);
     $form->setConstants(array('section' => 'shipping'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartshippingrate_id' => $this->getId()));
         $form->addElement('hidden', 'cartshippingrate_id');
         $defaultValues['cartshippingrate_state'] = $this->getState();
         $defaultValues['cartshippingrate_country'] = $this->getCountry();
         $defaultValues['cartshippingrate_cost'] = $this->getCost();
         $form->setDefaults($defaultValues);
     }
     $countrySelect = array('onchange' => 'selectCountry();', 'id' => 'cartshippingrate_country');
     $form->addElement('select', 'cartshippingrate_country', 'Country', Form::getCountryArray(), $countrySelect);
     $form->addElement('select', 'cartshippingrate_state', 'Province/State', Form::getStatesArray("Canada"));
     $form->addElement('text', 'cartshippingrate_cost', 'Shipping Cost');
     $form->addElement('submit', 'cartshippingrate_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $selectedCountry = $form->exportValue('cartshippingrate_country');
         //Only if the selected country is Canada, insert the selected state.
         if (CartShippingRate::hasState($selectedCountry)) {
             $selectedState = $form->exportValue('cartshippingrate_state');
         } else {
             $selectedState = 0;
         }
         $this->setCountry($selectedCountry);
         $this->setState($selectedState);
         $this->setCost($form->exportValue('cartshippingrate_cost'));
         $this->save();
     }
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:40,代码来源:CartShippingRate.php

示例12: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/CartOrderProduct')
 {
     $form = new Form('CartOrderProduct_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartorderproduct_orders_products_id' => $this->getId()));
         $form->addElement('hidden', 'cartorderproduct_orders_products_id');
         $defaultValues['cartorderproduct_orderId'] = $this->getOrderId();
         $defaultValues['cartorderproduct_product'] = $this->getProduct()->getId();
         $defaultValues['cartorderproduct_model'] = $this->getModel();
         $defaultValues['cartorderproduct_name'] = $this->getName();
         $defaultValues['cartorderproduct_price'] = $this->getPrice();
         $defaultValues['cartorderproduct_finalPrice'] = $this->getFinalPrice();
         $defaultValues['cartorderproduct_tax'] = $this->getTax();
         $defaultValues['cartorderproduct_quantity'] = $this->getQuantity();
         $defaultValues['cartorderproduct_oneTimeCharges'] = $this->getOneTimeCharges();
         $defaultValues['cartorderproduct_pricedByAttribute'] = $this->getPricedByAttribute();
         $defaultValues['cartorderproduct_isFree'] = $this->getIsFree();
         $defaultValues['cartorderproduct_discountType'] = $this->getDiscountType();
         $defaultValues['cartorderproduct_discountTypeFrom'] = $this->getDiscountTypeFrom();
         $defaultValues['cartorderproduct_prid'] = $this->getPrid();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartorderproduct_orderId', 'orderId');
     $form->addElement('text', 'cartorderproduct_product', 'product');
     $form->addElement('text', 'cartorderproduct_model', 'model');
     $form->addElement('text', 'cartorderproduct_name', 'name');
     $form->addElement('text', 'cartorderproduct_price', 'price');
     $form->addElement('text', 'cartorderproduct_finalPrice', 'finalPrice');
     $form->addElement('text', 'cartorderproduct_tax', 'tax');
     $form->addElement('text', 'cartorderproduct_quantity', 'quantity');
     $form->addElement('text', 'cartorderproduct_oneTimeCharges', 'oneTimeCharges');
     $form->addElement('text', 'cartorderproduct_pricedByAttribute', 'pricedByAttribute');
     $form->addElement('text', 'cartorderproduct_isFree', 'isFree');
     $form->addElement('text', 'cartorderproduct_discountType', 'discountType');
     $form->addElement('text', 'cartorderproduct_discountTypeFrom', 'discountTypeFrom');
     $form->addElement('text', 'cartorderproduct_prid', 'prid');
     $form->addElement('submit', 'cartorderproduct_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setOrderId($form->exportValue('cartorderproduct_orderId'));
         $this->setProduct($form->exportValue('cartorderproduct_product'));
         $this->setModel($form->exportValue('cartorderproduct_model'));
         $this->setName($form->exportValue('cartorderproduct_name'));
         $this->setPrice($form->exportValue('cartorderproduct_price'));
         $this->setFinalPrice($form->exportValue('cartorderproduct_finalPrice'));
         $this->setTax($form->exportValue('cartorderproduct_tax'));
         $this->setQuantity($form->exportValue('cartorderproduct_quantity'));
         $this->setOneTimeCharges($form->exportValue('cartorderproduct_oneTimeCharges'));
         $this->setPricedByAttribute($form->exportValue('cartorderproduct_pricedByAttribute'));
         $this->setIsFree($form->exportValue('cartorderproduct_isFree'));
         $this->setDiscountType($form->exportValue('cartorderproduct_discountType'));
         $this->setDiscountTypeFrom($form->exportValue('cartorderproduct_discountTypeFrom'));
         $this->setPrid($form->exportValue('cartorderproduct_prid'));
         $this->save();
     }
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:63,代码来源:CartOrderProduct.php

示例13: array

Debug::enable();
$countries = array('Select your country', 'Europe' => array('CZ' => 'Česká republika', 'SK' => 'Slovakia'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
// Step 1: Define form with validation rules
$form = new Form();
$form->encoding = 'ISO-8859-1';
// group Personal data
$form->addGroup('Personal data');
$form->addText('name', 'Your name:', 35);
$form->addMultiSelect('country', 'Country:')->skipFirst()->setItems($countries, FALSE);
$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()) {
        header('Content-type: text/html; charset=utf-8');
        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' => 'Žluťoučký kůň', 'userid' => 'kůň', 'note' => 'жед', 'country' => 'Česká republika');
    $form->setDefaults($defaults);
开发者ID:vrana,项目名称:nette,代码行数:31,代码来源:custom-encoding.php

示例14: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/InstantMessage')
 {
     $form = new Form('InstantMessage_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->id)) {
         $form->setConstants(array('instantmessage_id' => $this->getId()));
         $form->addElement('hidden', 'instantmessage_id');
         $defaultValues['instantmessage_from'] = $this->getFrom()->getId();
         $defaultValues['instantmessage_to'] = $this->getTo()->getId();
         $defaultValues['instantmessage_namespace'] = $this->getNamespace();
         $defaultValues['instantmessage_thread'] = $this->getThread();
         $defaultValues['instantmessage_message'] = $this->getMessage();
         $defaultValues['instantmessage_read'] = $this->getRead();
         $defaultValues['instantmessage_timestamp'] = $this->getTimestamp();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'instantmessage_from', 'from /* Fill in text */');
     $form->addElement('text', 'instantmessage_to', 'to /* Fill in text */');
     $form->addElement('text', 'instantmessage_namespace', 'namespace /* Fill in text */');
     $form->addElement('text', 'instantmessage_thread', 'thread /* Fill in text */');
     $form->addElement('text', 'instantmessage_message', 'message /* Fill in text */');
     $form->addElement('text', 'instantmessage_read', 'read /* Fill in text */');
     $form->addElement('text', 'instantmessage_timestamp', 'timestamp /* Fill in text */');
     $form->addElement('submit', 'instantmessage_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setFrom($form->exportValue('instantmessage_from'));
         $this->setTo($form->exportValue('instantmessage_to'));
         $this->setNamespace($form->exportValue('instantmessage_namespace'));
         $this->setThread($form->exportValue('instantmessage_thread'));
         $this->setMessage($form->exportValue('instantmessage_message'));
         $this->setRead($form->exportValue('instantmessage_read'));
         $this->setTimestamp($form->exportValue('instantmessage_timestamp'));
         $this->save();
     }
     return $form;
 }
开发者ID:swat30,项目名称:safeballot,代码行数:42,代码来源:InstantMessage.php

示例15: forgot

 /**
  * Displays and processes the forgotten password system
  * @access public
  */
 public function forgot()
 {
     $form = new Form();
     $form->addFields(array('user'));
     // process the form if submitted
     if ($form->isSubmitted()) {
         // generate a new password
         $new_pass = $this->makePassword();
         // load the account
         $auth = model()->open('users');
         $user = $auth->quickSelectSingle($form->cv('user'), 'username');
         if (is_array($user)) {
             // update the account
             $user['password'] = $user['password_confirm'] = $new_pass;
             $auth->update($user, $user['id']);
             if (app()->db->Affected_Rows()) {
                 app()->mail->AddAddress($form->cv('user'));
                 app()->mail->From = app()->config('email_sender');
                 app()->mail->FromName = app()->config('email_sender_name');
                 app()->mail->Mailer = "mail";
                 app()->mail->ContentType = 'text/html';
                 app()->mail->Subject = app()->config('password_reset_subject');
                 app()->mail->Body = str_replace('{new_pass}', $new_pass, app()->config('password_reset_body'));
                 app()->mail->Send();
                 app()->mail->ClearAddresses();
                 return 1;
             }
         } else {
             return -1;
         }
     }
     template()->set(array('form' => $form));
     return false;
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:38,代码来源:User.php


注:本文中的Form::isSubmitted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。