[ Index ]

PHP Cross Reference of moodle-2.8

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 <[email protected]>
  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 <[email protected]>
  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      function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) {
  49          parent::HTML_QuickForm_submit($elementName, $value, $attributes);
  50      }
  51  
  52      /**
  53       * Called by HTML_QuickForm whenever form event is made on this element
  54       *
  55       * @param string $event Name of event
  56       * @param mixed $arg event arguments
  57       * @param object $caller calling object
  58       */
  59      function onQuickFormEvent($event, $arg, &$caller)
  60      {
  61          switch ($event) {
  62              case 'createElement':
  63                  parent::onQuickFormEvent($event, $arg, $caller);
  64                  if ($caller->isNoSubmitButton($arg[0])){
  65                      //need this to bypass client validation
  66                      //for buttons that submit but do not process the
  67                      //whole form.
  68                      $onClick = $this->getAttribute('onclick');
  69                      $skip = 'skipClientValidation = true;';
  70                      $onClick = ($onClick !== null)?$skip.' '.$onClick:$skip;
  71                      $this->updateAttributes(array('onclick'=>$onClick));
  72                  }
  73                  return true;
  74                  break;
  75          }
  76          return parent::onQuickFormEvent($event, $arg, $caller);
  77  
  78      }
  79  
  80      /**
  81       * Slightly different container template when frozen. Don't want to display a submit
  82       * button if the form is frozen.
  83       *
  84       * @return string
  85       */
  86      function getElementTemplateType(){
  87          if ($this->_flagFrozen){
  88              return 'nodisplay';
  89          } else {
  90              return 'actionbuttons';
  91          }
  92      }
  93  
  94      /**
  95       * Freeze the element so that only its value is returned
  96       */
  97      function freeze(){
  98          $this->_flagFrozen = true;
  99      }
 100  
 101  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1