[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/Form/Action/ -> conditional_enable.php (source)

   1  <?php
   2  /**
   3   * Horde_Form_Action_conditional_enable is a Horde_Form_Action that
   4   * enables or disables an element based on the value of another element
   5   *
   6   * Format of the $params passed to the constructor:
   7   * <pre>
   8   *  $params = array(
   9   *      'target'  => '[name of element this is conditional on]',
  10   *      'enabled' => 'true' | 'false',
  11   *      'values'  => array([target values to check])
  12   *  );
  13   * </pre>
  14   *
  15   * So $params = array('foo', 'true', array(1, 2)) will enable the field this
  16   * action is attached to if the value of 'foo' is 1 or 2, and disable it
  17   * otherwise.
  18   *
  19   * $Horde: framework/Form/Form/Action/conditional_enable.php,v 1.4.10.3 2006/01/01 21:28:17 jan Exp $
  20   *
  21   * Copyright 2002-2006 Matt Kynaston <matt@kynx.org>
  22   *
  23   * See the enclosed file COPYING for license information (LGPL). If you
  24   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  25   *
  26   * @author  Matt Kynaston <matt@kynx.org>
  27   * @package Horde_Form
  28   */
  29  class Horde_Form_Action_conditional_enable extends Horde_Form_Action {
  30  
  31      var $_trigger = array('onload');
  32  
  33      function getActionScript(&$form, $renderer, $varname)
  34      {
  35          Horde::addScriptFile('form_helpers.js', 'horde', true);
  36  
  37          $form_name = $form->getName();
  38          $target = $this->_params['target'];
  39          $enabled = $this->_params['enabled'];
  40          if (!is_string($enabled)) {
  41              $enabled = ($enabled) ? 'true' : 'false';
  42          }
  43          $vals = $this->_params['values'];
  44          $vals = (is_array($vals)) ? $vals : array($vals);
  45          $args = "'$varname', $enabled, '" . implode("','", $vals) . "'";
  46  
  47          return "if (addEvent(document.$form_name.$target, 'onchange', \"checkEnabled(this, $args);\")) { "
  48              . "  checkEnabled(document.$form_name.$varname, $args); "
  49              . '};';
  50      }
  51  
  52  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7