Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • Button
  • Checkbox
  • FormControl
  • HiddenField
  • ImageButton
  • MultiSelectBox
  • RadioList
  • SelectBox
  • SubmitButton
  • TextArea
  • TextBase
  • TextInput
  • UploadControl
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  * @package Nette\Forms\Controls
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Submittable button control.
 17:  *
 18:  * @author     David Grudl
 19:  *
 20:  * @property-read bool $submittedBy
 21:  * @property   mixed $validationScope
 22:  * @package Nette\Forms\Controls
 23:  */
 24: class SubmitButton extends Button implements ISubmitterControl
 25: {
 26:     /** @var array of function(SubmitButton $sender); Occurs when the button is clicked and form is successfully validated */
 27:     public $onClick;
 28: 
 29:     /** @var array of function(SubmitButton $sender); Occurs when the button is clicked and form is not validated */
 30:     public $onInvalidClick;
 31: 
 32:     /** @var mixed */
 33:     private $validationScope = TRUE;
 34: 
 35: 
 36:     /**
 37:      * @param  string  caption
 38:      */
 39:     public function __construct($caption = NULL)
 40:     {
 41:         parent::__construct($caption);
 42:         $this->control->type = 'submit';
 43:     }
 44: 
 45: 
 46:     /**
 47:      * Sets 'pressed' indicator.
 48:      * @param  bool
 49:      * @return self
 50:      */
 51:     public function setValue($value)
 52:     {
 53:         if ($this->value = $value !== NULL) {
 54:             $this->getForm()->setSubmittedBy($this);
 55:         }
 56:         return $this;
 57:     }
 58: 
 59: 
 60:     /**
 61:      * Tells if the form was submitted by this button.
 62:      * @return bool
 63:      */
 64:     public function isSubmittedBy()
 65:     {
 66:         return $this->getForm()->isSubmitted() === $this;
 67:     }
 68: 
 69: 
 70:     /**
 71:      * Sets the validation scope. Clicking the button validates only the controls within the specified scope.
 72:      * @param  mixed
 73:      * @return self
 74:      */
 75:     public function setValidationScope($scope)
 76:     {
 77:         // TODO: implement groups
 78:         $this->validationScope = (bool) $scope;
 79:         $this->control->formnovalidate = !$this->validationScope;
 80:         return $this;
 81:     }
 82: 
 83: 
 84:     /**
 85:      * Gets the validation scope.
 86:      * @return mixed
 87:      */
 88:     final public function getValidationScope()
 89:     {
 90:         return $this->validationScope;
 91:     }
 92: 
 93: 
 94:     /**
 95:      * Fires click event.
 96:      * @return void
 97:      */
 98:     public function click()
 99:     {
100:         $this->onClick($this);
101:     }
102: 
103: 
104:     /**
105:      * Submitted validator: has been button pressed?
106:      * @return bool
107:      */
108:     public static function validateSubmitted(ISubmitterControl $control)
109:     {
110:         return $control->isSubmittedBy();
111:     }
112: 
113: }
114: 
Nette Framework 2.0.13 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.8.0