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_updatefield is a Horde_Form_Action that updates
 4:  * the value of one Horde_Form variable as the variable the action is
 5:  * attached to is updated.
 6:  *
 7:  * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
 8:  *
 9:  * See the enclosed file COPYING for license information (LGPL). If you
10:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
11:  *
12:  * @author  Chuck Hagenbuch <chuck@horde.org>
13:  * @package Form
14:  */
15: class Horde_Form_Action_updatefield extends Horde_Form_Action {
16: 
17:     var $_trigger = array('onchange', 'onload', 'onkeyup');
18: 
19:     function getActionScript(&$form, &$renderer, $varname)
20:     {
21:         return 'updateField' . $this->id() . '();';
22:     }
23: 
24:     function setValues(&$vars, $sourceVal, $arrayVal = false)
25:     {
26:     }
27: 
28:     function printJavaScript()
29:     {
30:         $this->_printJavaScriptStart();
31:         $pieces = explode('%s', $this->_params['format']);
32:         $fields = $this->_params['fields'];
33:         $val_first = (substr($this->_params['format'], 0, 2) == '%s');
34:         if ($val_first) {
35:             array_shift($pieces);
36:         }
37:         if (substr($this->_params['format'], -2) == '%s') {
38:             array_pop($pieces);
39:         }
40: 
41:         $args = array();
42:         if ($val_first) {
43:             $args[] = "document.getElementById('" . array_shift($fields) . "').value";
44:         }
45:         while (count($pieces)) {
46:             $args[] = "'" . array_shift($pieces) . "'";
47:             $args[] = "document.getElementById('" . array_shift($fields) . "').value";
48:         }
49: ?>
50: // Updater for <?php echo $this->getTarget() ?>.
51: function updateField<?php echo $this->id() ?>()
52: {
53:     var target = document.getElementById('<?php echo $this->getTarget() ?>');
54:     if (target) {
55:         target.value = (<?php echo implode(' + ', str_replace("\n", "\\n", $args)) ?>).replace(/(^ +| +$)/, '').replace(/ +/g, ' ');
56:     }
57: }<?php
58:         $this->_printJavaScriptEnd();
59:     }
60: 
61: }
62: 
API documentation generated by ApiGen