[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/form/ -> submit.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  
  18  /**
  19   * submit type form element
  20   *
  21   * Contains HTML class for a submit type element
  22   *
  23   * @package   core_form
  24   * @copyright 2006 Jamie Pratt <me@jamiep.org>
  25   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  
  28  require_once("HTML/QuickForm/submit.php");
  29  
  30  /**
  31   * submit type form element
  32   *
  33   * HTML class for a submit type element
  34   *
  35   * @package   core_form
  36   * @category  form
  37   * @copyright 2006 Jamie Pratt <me@jamiep.org>
  38   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  class MoodleQuickForm_submit extends HTML_QuickForm_submit {
  41      /**
  42       * constructor
  43       *
  44       * @param string $elementName (optional) name of the field
  45       * @param string $value (optional) field label
  46       * @param string $attributes (optional) Either a typical HTML attribute string or an associative array
  47       */
  48      public function __construct($elementName=null, $value=null, $attributes=null) {
  49          parent::__construct($elementName, $value, $attributes);
  50      }
  51  
  52      /**
  53       * Old syntax of class constructor. Deprecated in PHP7.
  54       *
  55       * @deprecated since Moodle 3.1
  56       */
  57      public function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) {
  58          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
  59          self::__construct($elementName, $value, $attributes);
  60      }
  61  
  62      /**
  63       * Called by HTML_QuickForm whenever form event is made on this element
  64       *
  65       * @param string $event Name of event
  66       * @param mixed $arg event arguments
  67       * @param object $caller calling object
  68       */
  69      function onQuickFormEvent($event, $arg, &$caller)
  70      {
  71          switch ($event) {
  72              case 'createElement':
  73                  parent::onQuickFormEvent($event, $arg, $caller);
  74                  if ($caller->isNoSubmitButton($arg[0])){
  75                      //need this to bypass client validation
  76                      //for buttons that submit but do not process the
  77                      //whole form.
  78                      $onClick = $this->getAttribute('onclick');
  79                      $skip = 'skipClientValidation = true;';
  80                      $onClick = ($onClick !== null)?$skip.' '.$onClick:$skip;
  81                      $this->updateAttributes(array('onclick'=>$onClick));
  82                  }
  83                  return true;
  84                  break;
  85          }
  86          return parent::onQuickFormEvent($event, $arg, $caller);
  87  
  88      }
  89  
  90      /**
  91       * Slightly different container template when frozen. Don't want to display a submit
  92       * button if the form is frozen.
  93       *
  94       * @return string
  95       */
  96      function getElementTemplateType(){
  97          if ($this->_flagFrozen){
  98              return 'nodisplay';
  99          } else {
 100              return 'actionbuttons';
 101          }
 102      }
 103  
 104      /**
 105       * Freeze the element so that only its value is returned
 106       */
 107      function freeze(){
 108          $this->_flagFrozen = true;
 109      }
 110  
 111  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1