Changeset 3815

Show
Ignore:
Timestamp:
02/26/07 01:12:18 (5 years ago)
Author:
gregmac
Message:

Add HTML_QuickForm::addOptionalGroup() function (and optionalgroup element) to add an element that can be enabled/disabled with a checkbox beside it. If disabled, the element sends a 'standard' value (distict from default) which acts much like a 'system default' (default is generally used for loading old values that the user previously saved)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/quickform/amp_conf/htdocs/admin/common/HTML/QuickForm.php

    r3661 r3815  
    4949            'xbutton'       =>array('HTML/QuickForm/xbutton.php','HTML_QuickForm_xbutton'), 
    5050            'advmultiselect'=>array('HTML/QuickForm/advmultiselect.php','HTML_QuickForm_advmultiselect'), 
     51            'optionalgroup' =>array('HTML/QuickForm/optionalgroup.php','HTML_QuickForm_optionalgroup'), 
    5152        ); 
    5253 
     
    597598    { 
    598599        if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { 
    599            $elementObject = &$element; 
    600            $elementObject->onQuickFormEvent('updateValue', null, $this); 
     600            $elementObject = &$element; 
     601            $elementObject->onQuickFormEvent('updateValue', null, $this); 
    601602        } else { 
    602603            $args = func_get_args(); 
     
    727728        return $group; 
    728729    } // end func addGroup 
     730     
     731    // }}} 
     732  // {{{ addOptionalElement() 
     733 
     734    /** 
     735     * Adds an optional element, using a checkbox 
     736     * @param    array      $elements       array of elements composing the group 
     737     * @param    string     $name           (optional)group name 
     738     * @param    string     $groupLabel     (optional)group label 
     739     * @param    string     $separator      (optional)string to separate elements 
     740     * @param    string     $appendName     (optional)specify whether the group name should be 
     741     *                                      used in the form element name ex: group[element] 
     742     * @return   object     reference to added group of elements 
     743     * @since    2.8 
     744     * @access   public 
     745     * @throws   PEAR_Error 
     746     */ 
     747    function &addOptionalElement($element, $name, $standardValue, $groupLabel /*, optional multiple params.. */) 
     748    { 
     749        if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { 
     750           $elementObject = &$element; 
     751        } else { 
     752      // get arguments for elementObject 
     753            $args = array_slice(func_get_args(),3);  
     754      array_unshift($args, null); // stick null on the beginning (element name) 
     755       
     756      $elementObject =& $this->_loadElement('addElement', $element, $args); 
     757            if (PEAR::isError($elementObject)) { 
     758                return $elementObject; 
     759            } 
     760        } 
     761         
     762    $group =& $this->addElement('optionalgroup', $standardValue, $name, $groupLabel, $elementObject); 
     763        return $group; 
     764     
     765    } // end func addOptionalElement2 
    729766     
    730767    // }}}