Changeset 1156

Show
Ignore:
Timestamp:
11/08/08 17:38:34 (2 months ago)
Author:
laurentj
Message:

ticket #700: the way how modified controls were tracked was not very useful. implementation has been changed now. removed setModifiedFlag and added resetModifiedControlsList.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r1138 r1156  
    105105 
    106106    /** 
    107      * list of modified controls 
    108      * keys are name of control, value is the old value of the control 
    109      * @var array 
    110      */ 
    111     protected $modifiedControls = array(); 
    112     /** 
    113107     * the form selector 
    114108     * @var string 
     
    139133    public function initFromRequest(){ 
    140134        $req = $GLOBALS['gJCoord']->request; 
    141         $this->modifiedControls=array(); 
    142135        foreach($this->rootControls as $name=>$ctrl){ 
    143136            if(!$this->container->isActivated($name) || $this->container->isReadOnly($name)) 
     
    450443    } 
    451444 
    452  
    453     function setModifiedFlag($name){ 
    454         $this->modifiedControls[$name] = $this->container->data[$name]; 
    455     } 
    456  
    457  
    458445    /** 
    459446     * deactivate (or reactivate) a control 
     
    492479    } 
    493480 
    494  
    495481    /** 
    496482     * @return jFormsDataContainer 
     
    533519    public function getHtmlEditors(){ return $this->htmleditors; } 
    534520 
    535      /** 
     521    /** 
     522     * call this method after initilization of the form, in order to track 
     523     * modified controls 
     524     * @since 1.1 
     525     */ 
     526    public function resetModifiedControlsList(){ 
     527        $this->container->originalData = $this->container->data; 
     528    } 
     529 
     530    /** 
    536531     * @return array key=control id,  value=old value 
    537532     * @since 1.1 
    538533     */ 
    539     public function getModifiedControls(){ return $this->modifiedControls; } 
     534    public function getModifiedControls(){ 
     535        if(count($this->container->originalData)) 
     536            return array_diff($this->container->originalData, $this->container->data); 
     537        else 
     538            return $this->container->data; 
     539    } 
    540540 
    541541    /** 
  • trunk/lib/jelix/forms/jFormsControl.class.php

    r1149 r1156  
    8282 
    8383    function setData($value) { 
    84         if($this->container->data[$this->ref] != $value) 
    85             $this->form->setModifiedFlag($this->ref); 
    8684        $this->container->data[$this->ref] = $value; 
    8785    } 
  • trunk/lib/jelix/forms/jFormsDataContainer.class.php

    r1030 r1156  
    2121     */ 
    2222    public $data = array(); 
    23  
     23     
     24    /** 
     25     * contains data provided by the user in each controls 
     26     * @var array 
     27     * @see jFormsBase::getModifiedControls() 
     28     * @see jFormsBase::resetModifiedControlsList() 
     29     */ 
     30    public $originalData = array(); 
     31     
    2432    /** 
    2533     * internal use. Used by controls object to store some private data. (captcha for example) 
Download in other formats: Unified Diff Zip Archive