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


PHP Form::isSubmitted方法代码示例

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


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

示例1: shouldSkip

 /**
  * @param IComponent
  * @return bool
  */
 protected function shouldSkip($component)
 {
     if ($component instanceof Controls\Button) {
         return TRUE;
     }
     if ($this->isValidating() && $this->form->isAnchored() && ($submittedBy = $this->form->isSubmitted()) && $submittedBy instanceof ISubmitterControl) {
         $controls = $submittedBy->getValidationScope();
         if ($controls === NULL) {
             return FALSE;
         }
         foreach ($controls as $control) {
             if ($control === $component) {
                 return FALSE;
             }
             if ($control instanceof Container && array_search($component, $control->getComponents(TRUE), TRUE)) {
                 return FALSE;
             }
         }
         return TRUE;
     }
     return FALSE;
 }
开发者ID:librette,项目名称:doctrine-forms,代码行数:26,代码来源:Mapper.php

示例2: array

$form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
$form->addText('street', 'Street');
$form->addText('city', 'City')->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')->addRule(Form::FILLED, 'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3)->setOption('description', '(at least 3 characters)');
$form->addPassword('password2', 'Reenter password')->addConditionOn($form['password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
$form->addFile('avatar', 'Picture');
$form->addHidden('userid');
$form->addTextArea('note', 'Comment');
// group for buttons
$form->addGroup();
$form->addSubmit('submit', '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);
}
开发者ID:jakubkulhan,项目名称:nette,代码行数:31,代码来源:custom-rendering.php

示例3: Form

use FileDownloader\Downloader\AdvancedDownloader;
use FileDownloader\FDTools;
use FileDownloader\FileDownload;
use Nette\Diagnostics\Debugger;
use Nette\Forms\Form;
// Generate form
$f = new Form("upload-form");
$f->getElementPrototype()->id = "frm";
$f->setMethod("GET");
$f->addSelect("speed", "Speed", array(1 => "1byte/s", 50 => "50bytes/s", 512 => "512bytes/s", 1 * FDTools::KILOBYTE => "1kb/s", 5 * FDTools::KILOBYTE => "5kb/s", 20 * FDTools::KILOBYTE => "20kb/s", 32 * FDTools::KILOBYTE => "32kb/s", 50 * FDTools::KILOBYTE => "50kb/s", 64 * FDTools::KILOBYTE => "64kb/s", 100 * FDTools::KILOBYTE => "100kb/s", 128 * FDTools::KILOBYTE => "128kb/s", 200 * FDTools::KILOBYTE => "200kb/s", 256 * FDTools::KILOBYTE => "256kb/s", 300 * FDTools::KILOBYTE => "300kb/s", 512 * FDTools::KILOBYTE => "512kb/s", 1 * FDTools::MEGABYTE => "1mb/s", 2 * FDTools::MEGABYTE => "2mb/s", 5 * FDTools::MEGABYTE => "5mb/s", 10 * FDTools::MEGABYTE => "10mb/s", 0 => "Unlimited"));
$f->addText("filename", "Filename")->addRule(Form::FILLED, "You must fill name!");
$f->addSelect("size", "Size", array(1 => "1MB", 4 => "4MB", 8 => "8MB", 16 => "16MB", 32 => "32MB", 64 => "64MB", 128 => "128MB", 256 => "256MB", 512 => "512MB"));
$f->addSelect("log", "Log called events?", array(0 => "No", 1 => "Yes (may cause CPU load)"));
$f->addSubmit("download", "Download!");
$f->setDefaults(array("speed" => 50, "filename" => "Some horrible file name - ěščřžýáíé.bin", "size" => 8, "log" => 1));
if ($f->isSubmitted() and $f->isValid()) {
    Debugger::enable(Debugger::PRODUCTION);
    // Log errors to file!
    $val = $f->getValues();
    $location = dirname(__FILE__) . "/cache/test-" . $val["size"] . "MB.tmp";
    if (!file_exists($location)) {
        generateFile($location, $val["size"] * 1024);
    }
    /* Interface with getters and setters */
    $file = new FileDownload();
    $file->sourceFile = $location;
    $file->transferFileName = $val["filename"];
    $file->speedLimit = (int) $val["speed"];
    //$file->mimeType = $val["mimeType"];
    /* Functions defined in example_library.php */
    if ($val["log"] == 1) {
开发者ID:jkuchar,项目名称:FileDownloader-example,代码行数:31,代码来源:index.php

示例4: processActions

 /**
  * Do the magic
  */
 public function processActions()
 {
     // WP_List_Table export
     \SimpleSubscribe\TableSubscribes::process();
     // settings form
     if ($this->formSettings->isSubmitted() && $this->formSettings->isValid()) {
         $values = $this->formSettings->getValues(TRUE);
         // if there are cateogires selected, and ALL as well, uncheck remaining
         if (count(array_filter($values['cat'])) > 0 && $values['cat']['0'] == TRUE) {
             foreach ($values['cat'] as $key => $value) {
                 $values['cat'][$key] = FALSE;
                 $this->formSettings['cat'][$key]->value = FALSE;
             }
             $values['cat']['0'] = TRUE;
             $this->formSettings['cat']['0']->value = TRUE;
             // if there is other category selected, unselect ALL
         } elseif (count(array_filter($values['cat'])) > 1) {
             $values['cat']['0'] = FALSE;
             $this->formSettings['cat']['0']->value = FALSE;
             // if there's no category selected, select ALL
         } elseif (!in_array(TRUE, $values['cat'])) {
             $values['cat']['0'] = TRUE;
             $this->formSettings['cat']['0']->value = TRUE;
         }
         $this->settings->saveSettings($values);
         $this->addNotice('updated', 'Settings successfully saved.');
     } elseif ($this->formSettings->hasErrors()) {
         foreach ($this->formSettings->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // email template (saved in settings table tho)
     if ($this->formEmailTemplate->isSubmitted() && $this->formEmailTemplate->isValid()) {
         $this->settings->saveSettings($this->formEmailTemplate->getValues(TRUE));
         $this->addNotice('updated', 'Settings successfully saved.');
     } elseif ($this->formEmailTemplate->hasErrors()) {
         foreach ($this->formEmailTemplate->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // mass email
     if ($this->formEmail->isSubmitted() && $this->formEmail->isValid()) {
         try {
             $this->email->sendMassEmail($this->formEmail->getValues(TRUE));
             $this->addNotice('updated', 'Email successfully sent.');
         } catch (EmailException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formEmail->hasErrors()) {
         foreach ($this->formEmail->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // subscriber form
     if ($this->formSubscriber->isSubmitted() && $this->formSubscriber->isValid()) {
         try {
             $this->subscribers->addThruAdmin($this->formSubscriber->getValues());
             $this->addNotice('updated', 'Subscriber successfully added.');
         } catch (RepositarySubscribersException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formSubscriber->hasErrors()) {
         foreach ($this->formSubscriber->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // wp subscriber form
     if ($this->formSubscriberWp->isSubmitted() && $this->formSubscriberWp->isValid()) {
         try {
             $users = $this->formSubscriberWp->getValues(TRUE);
             $this->subscribers->addWpRegistered($users['users']);
             $this->addNotice('updated', 'Subscriber(s) successfully added.');
         } catch (RepositarySubscribersException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formSubscriberWp->hasErrors()) {
         foreach ($this->formSubscriberWp->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // email preview form
     if ($this->formEmailPreview->isSubmitted() && $this->formEmailPreview->isValid()) {
         try {
             $this->email->sendEmailPreview($this->formEmailPreview->getValues(TRUE));
             $this->addNotice('updated', 'Email Preview successfully sent.');
         } catch (EmailException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formEmailPreview->hasErrors()) {
         foreach ($this->formEmailPreview->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
 }
开发者ID:hkarriche,项目名称:wordpress,代码行数:97,代码来源:Admin.php

示例5: Form

 * - for the best experience, use the latest version of browser (Internet Explorer 9, Firefox 4, Chrome 5, Safari 5, Opera 9)
 */
require_once __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form, Nette\Debug;
Debug::enable();
// Step 1: Define form with validation rules
$form = new Form();
$form->addGroup();
$form->addText('query', 'Search:')->setType('search')->setAttribute('autofocus');
$form->addText('count', 'Number of results:')->setType('number')->setDefaultValue(10)->addRule(Form::INTEGER, 'Must be numeric value')->addRule(Form::RANGE, 'Must be in range from %d to %d', array(1, 100));
$form->addText('precision', 'Precision:')->setType('range')->setDefaultValue(50)->addRule(Form::INTEGER, 'Precision must be numeric value')->addRule(Form::RANGE, 'Precision must be in range from %d to %d', array(0, 100));
$form->addText('email', 'Send to e-mail:')->setType('email')->setAttribute('autocomplete', 'off')->setAttribute('placeholder', 'Optional, but Recommended')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
// ... then check email
$form->addSubmit('submit', 'Send');
// Step 2: Check if form was submitted?
if ($form->isSubmitted() && $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;
    }
}
// Step 3: Render form
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
开发者ID:jakubkulhan,项目名称:nette,代码行数:30,代码来源:html5.php


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