Overview

Packages

  • Form
  • None

Classes

  • Horde_Form
  • Horde_Form_Action
  • Horde_Form_Action_conditional_enable
  • Horde_Form_Action_conditional_setvalue
  • Horde_Form_Action_ConditionalEnable
  • Horde_Form_Action_ConditionalSetValue
  • Horde_Form_Action_reload
  • Horde_Form_Action_setcursorpos
  • Horde_Form_Action_submit
  • Horde_Form_Action_sum_fields
  • Horde_Form_Action_updatefield
  • Horde_Form_Renderer
  • Horde_Form_Translation
  • Horde_Form_Type
  • Horde_Form_Type_address
  • Horde_Form_Type_addresslink
  • Horde_Form_Type_assign
  • Horde_Form_Type_boolean
  • Horde_Form_Type_captcha
  • Horde_Form_Type_category
  • Horde_Form_Type_cellphone
  • Horde_Form_Type_colorpicker
  • Horde_Form_Type_countedtext
  • Horde_Form_Type_country
  • Horde_Form_Type_creditcard
  • Horde_Form_Type_date
  • Horde_Form_Type_datetime
  • Horde_Form_Type_dblookup
  • Horde_Form_Type_description
  • Horde_Form_Type_email
  • Horde_Form_Type_emailConfirm
  • Horde_Form_Type_enum
  • Horde_Form_Type_figlet
  • Horde_Form_Type_file
  • Horde_Form_Type_header
  • Horde_Form_Type_hourminutesecond
  • Horde_Form_Type_image
  • Horde_Form_Type_int
  • Horde_Form_Type_intlist
  • Horde_Form_Type_invalid
  • Horde_Form_Type_ip6address
  • Horde_Form_Type_ipaddress
  • Horde_Form_Type_keyval_multienum
  • Horde_Form_Type_link
  • Horde_Form_Type_longtext
  • Horde_Form_Type_matrix
  • Horde_Form_Type_mlenum
  • Horde_Form_Type_monthdayyear
  • Horde_Form_Type_monthyear
  • Horde_Form_Type_multienum
  • Horde_Form_Type_number
  • Horde_Form_Type_obrowser
  • Horde_Form_Type_octal
  • Horde_Form_Type_password
  • Horde_Form_Type_passwordconfirm
  • Horde_Form_Type_pgp
  • Horde_Form_Type_phone
  • Horde_Form_Type_radio
  • Horde_Form_Type_selectfiles
  • Horde_Form_Type_set
  • Horde_Form_Type_smime
  • Horde_Form_Type_sorter
  • Horde_Form_Type_sound
  • Horde_Form_Type_spacer
  • Horde_Form_Type_stringarray
  • Horde_Form_Type_stringlist
  • Horde_Form_Type_tableset
  • Horde_Form_Type_text
  • Horde_Form_Type_time
  • Horde_Form_Variable
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Horde_Form_Action_ConditionalEnable 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:  * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
20:  *
21:  * See the enclosed file COPYING for license information (LGPL). If you
22:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
23:  *
24:  * @author  Matt Kynaston <matt@kynx.org>
25:  * @package Form
26:  */
27: class Horde_Form_Action_ConditionalEnable extends Horde_Form_Action {
28: 
29:     var $_trigger = array('onload');
30: 
31:     function getActionScript(&$form, $renderer, $varname)
32:     {
33:         Horde::addScriptFile('form_helpers.js', 'horde');
34: 
35:         $form_name = $form->getName();
36:         $target = $this->_params['target'];
37:         $enabled = $this->_params['enabled'];
38:         if (!is_string($enabled)) {
39:             $enabled = ($enabled) ? 'true' : 'false';
40:         }
41:         $vals = $this->_params['values'];
42:         $vals = (is_array($vals)) ? $vals : array($vals);
43:         $args = "'$varname', $enabled, '" . implode("','", $vals) . "'";
44: 
45:         return "if (addEvent(document.getElementById('$form_name').$target, 'onchange', \"checkEnabled(this, $args);\")) { "
46:             . "  checkEnabled(document.getElementById('$form_name').$varname, $args); };";
47:     }
48: 
49: }
50: 
API documentation generated by ApiGen