Changeset 911

Show
Ignore:
Timestamp:
04/28/08 20:45:35 (3 months ago)
Author:
laurentj
Message:

jforms-group: work in progress #2

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r910 r911  
    137137            if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 
    138138                continue; 
    139             $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 
     139            $this->setData($name, $ctrl->getValueFromRequest($req), true); 
    140140        } 
    141141    } 
     
    150150            if(!$this->_container->isActivated($name)) 
    151151                continue; 
    152             $err = $ctrl->check($this); 
     152            $err = $ctrl->check(); 
    153153            if($err !== null) 
    154154                $this->_container->errors[$name]= $err; 
     
    464464    public function deactivate($name, $deactivation=true) { 
    465465        $this->_container->deactivate($name, $deactivation); 
     466        if($this->_controls[$name] implements jFormsControlGroups) { 
     467            $this->_controls[$name]->deactivate($this, $r); 
     468        } 
    466469    } 
    467470 
     
    482485    public function setReadOnly($name, $r = true) { 
    483486        $this->_container->setReadOnly($name, $r); 
     487        if($this->_controls[$name] implements jFormsControlGroups) { 
     488            $this->_controls[$name]->setReadOnly($this, $r); 
     489        } 
    484490    } 
    485491 
     
    661667            $this->_htmleditors [$control->ref] = $control; 
    662668 
     669        $control->setForm($this); 
     670 
    663671        if(!isset($this->_container->data[$control->ref])){ 
    664672            if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r910 r911  
    137137            if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 
    138138                continue; 
    139             $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 
     139            $this->setData($name, $ctrl->getValueFromRequest($req), true); 
    140140        } 
    141141    } 
     
    150150            if(!$this->_container->isActivated($name)) 
    151151                continue; 
    152             $err = $ctrl->check($this); 
     152            $err = $ctrl->check(); 
    153153            if($err !== null) 
    154154                $this->_container->errors[$name]= $err; 
     
    464464    public function deactivate($name, $deactivation=true) { 
    465465        $this->_container->deactivate($name, $deactivation); 
     466        if($this->_controls[$name] implements jFormsControlGroups) { 
     467            $this->_controls[$name]->deactivate($this, $r); 
     468        } 
    466469    } 
    467470 
     
    482485    public function setReadOnly($name, $r = true) { 
    483486        $this->_container->setReadOnly($name, $r); 
     487        if($this->_controls[$name] implements jFormsControlGroups) { 
     488            $this->_controls[$name]->setReadOnly($this, $r); 
     489        } 
    484490    } 
    485491 
     
    661667            $this->_htmleditors [$control->ref] = $control; 
    662668 
     669        $control->setForm($this); 
     670 
    663671        if(!isset($this->_container->data[$control->ref])){ 
    664672            if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r910 r911  
    137137            if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 
    138138                continue; 
    139             $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 
     139            $this->setData($name, $ctrl->getValueFromRequest($req), true); 
    140140        } 
    141141    } 
     
    150150            if(!$this->_container->isActivated($name)) 
    151151                continue; 
    152             $err = $ctrl->check($this); 
     152            $err = $ctrl->check(); 
    153153            if($err !== null) 
    154154                $this->_container->errors[$name]= $err; 
     
    464464    public function deactivate($name, $deactivation=true) { 
    465465        $this->_container->deactivate($name, $deactivation); 
     466        if($this->_controls[$name] implements jFormsControlGroups) { 
     467            $this->_controls[$name]->deactivate($this, $r); 
     468        } 
    466469    } 
    467470 
     
    482485    public function setReadOnly($name, $r = true) { 
    483486        $this->_container->setReadOnly($name, $r); 
     487        if($this->_controls[$name] implements jFormsControlGroups) { 
     488            $this->_controls[$name]->setReadOnly($this, $r); 
     489        } 
    484490    } 
    485491 
     
    661667            $this->_htmleditors [$control->ref] = $control; 
    662668 
     669        $control->setForm($this); 
     670 
    663671        if(!isset($this->_container->data[$control->ref])){ 
    664672            if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r910 r911  
    137137            if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 
    138138                continue; 
    139             $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 
     139            $this->setData($name, $ctrl->getValueFromRequest($req), true); 
    140140        } 
    141141    } 
     
    150150            if(!$this->_container->isActivated($name)) 
    151151                continue; 
    152             $err = $ctrl->check($this); 
     152            $err = $ctrl->check(); 
    153153            if($err !== null) 
    154154                $this->_container->errors[$name]= $err; 
     
    464464    public function deactivate($name, $deactivation=true) { 
    465465        $this->_container->deactivate($name, $deactivation); 
     466        if($this->_controls[$name] implements jFormsControlGroups) { 
     467            $this->_controls[$name]->deactivate($this, $r); 
     468        } 
    466469    } 
    467470 
     
    482485    public function setReadOnly($name, $r = true) { 
    483486        $this->_container->setReadOnly($name, $r); 
     487        if($this->_controls[$name] implements jFormsControlGroups) { 
     488            $this->_controls[$name]->setReadOnly($this, $r); 
     489        } 
    484490    } 
    485491 
     
    661667            $this->_htmleditors [$control->ref] = $control; 
    662668 
     669        $control->setForm($this); 
     670 
    663671        if(!isset($this->_container->data[$control->ref])){ 
    664672            if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r910 r911  
    2929    public $alertRequired=''; 
    3030 
     31    protected $form; 
     32    protected $container; 
     33 
     34 
    3135    function __construct($ref){ 
    3236        $this->ref = $ref; 
    3337        $this->datatype = new jDatatypeString(); 
     38    } 
     39 
     40    function setForm($form) { 
     41        $this->form = $form; 
     42        $this->container = $form->getContainer(); 
    3443    } 
    3544 
     
    4150    } 
    4251 
    43     function check($form){ 
    44         $value = $form->getContainer()->data[$this->ref]; 
     52    function check(){ 
     53        $value = $this->form->getContainer()->data[$this->ref]; 
    4554        if($value == '') { 
    4655            if($this->required) 
     
    4958            return jForms::ERRDATA_INVALID; 
    5059        }elseif($this->datatype instanceof jIFilteredDatatype) { 
    51             $form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 
     60            $this->form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 
    5261        } 
    5362        return null; 
     
    5867    } 
    5968 
    60     function getValueFromRequest($form, $request) { 
     69    function getValueFromRequest($request) { 
    6170        return $request->getParam($this->ref,''); 
    6271    } 
     
    136145    public $size=0; 
    137146 
    138     function check($form){ 
    139         if ($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     147    function check(){ 
     148        if ($this->form->getContainer()->data[$this->ref] == '' && $this->required) { 
    140149            return jForms::ERRDATA_REQUIRED; 
    141150        } 
     
    157166    public $primarySecret=''; 
    158167 
    159     function check($form){ 
    160         if($form->getContainer()->data[$this->ref] != $form->getData($this->primarySecret)) 
     168    function check(){ 
     169        if($this->container->data[$this->ref] != $this->form->getData($this->primarySecret)) 
    161170            return jForms::ERRDATA_INVALID; 
    162171        return null; 
     
    175184    public $valueOnUncheck='0'; 
    176185 
    177     function check($form){ 
    178         $value = $form->getContainer()->data[$this->ref]; 
     186    function check(){ 
     187        $value = $this->container->data[$this->ref]; 
    179188        if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 
    180189            return jForms::ERRDATA_INVALID; 
     
    182191    } 
    183192 
    184     function getValueFromRequest($form, $request) { 
     193    function getValueFromRequest($request) { 
    185194        $value = $request->getParam($this->ref); 
    186195        if($value){ 
     
    212221    public $type='output'; 
    213222 
    214     public function check($form){ 
     223    public function check(){ 
    215224        return null; 
    216225    } 
     
    229238    public $fileInfo = array(); 
    230239 
    231     function check($form){ 
     240    function check(){ 
    232241        if(isset($_FILES[$this->ref])) 
    233242            $this->fileInfo = $_FILES[$this->ref]; 
     
    256265    } 
    257266 
    258     function getValueFromRequest($form, $request) { 
     267    function getValueFromRequest($request) { 
    259268        if(isset($_FILES[$this->ref])){ 
    260269            return $_FILES[$this->ref]['name']; 
     
    277286    } 
    278287 
    279     function getValueFromRequest($form, $request) { 
     288    function getValueFromRequest($request) { 
    280289 
    281290        $value = $request->getParam($this->ref,''); 
     
    305314class jFormsControlReset extends jFormsControl { 
    306315    public $type='reset'; 
    307     public function check($form){ 
     316    public function check(){ 
    308317        return null; 
    309318    } 
     
    329338    public $question=''; 
    330339    public $required = true; 
    331     function check($form){ 
    332         $value = $form->getContainer()->data[$this->ref]; 
     340    function check(){ 
     341        $value = $this->container->data[$this->ref]; 
    333342        if($value == '') { 
    334343            return jForms::ERRDATA_REQUIRED; 
    335         }elseif($value != $form->getContainer()->privateData[$this->ref]){ 
     344        }elseif($value != $this->container->privateData[$this->ref]){ 
    336345            return jForms::ERRDATA_INVALID; 
    337346        } 
     
    339348    } 
    340349 
    341     function initExpectedValue($form){ 
     350    function initExpectedValue(){ 
    342351        $numbers = jLocale::get('jelix~captcha.number'); 
    343352        $id = rand(1,intval($numbers)); 
    344353        $this->question = jLocale::get('jelix~captcha.question.'.$id); 
    345         $form->getContainer()->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 
     354        $this->container->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 
    346355    } 
    347356} 
     
    387396    } 
    388397 
    389     function check($form){ 
    390         $value = $form->getContainer()->data[$this->ref]; 
     398    function check(){ 
     399        $value = $this->container->data[$this->ref]; 
    391400        if(is_array($value)){ 
    392401            if(count($value) == 0 && $this->required){ 
     
    419428    } 
    420429 
    421     function check($form){ 
    422         $value = $form->getContainer()->data[$this->ref]; 
     430    function check(){ 
     431        $value = $this->container->data[$this->ref]; 
    423432        if(is_array($value)){ 
    424433            if(!$this->multiple){ 
     
    445454    public $type="radiobuttons"; 
    446455 
    447     function check($form){ 
    448         if($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     456    function check(){ 
     457        if($this->container->data[$this->ref] == '' && $this->required) { 
    449458            return jForms::ERRDATA_REQUIRED; 
    450459        } 
     
    473482    protected $childControls = array(); 
    474483 
    475     function check($form){ 
    476         $check = parent::check($form); 
    477         $container = $form->getContainer(); 
     484    function check(){ 
     485        $check = parent::check(); 
    478486        foreach($this->childControls as $name => $ctrl) { 
    479487            $err = $ctrl->check($this); 
    480488            if($err !== null) 
    481                 $container->errors[$name]= $err; 
     489                $this->container->errors[$name]= $err; 
    482490        } 
    483491        return $check; 
     
    488496    } 
    489497 
    490     function getValueFromRequest($form, $request) { 
    491         $container = $form->getContainer(); 
     498    function getValueFromRequest($request) { 
    492499        foreach($this->childControls as $name => $ctrl) { 
    493             if(!$container->isActivated($name) || $container->isReadonly($name)) continue; 
    494             $form->setData($name, $ctrl->getValueFromRequest($form, $request),true); 
     500            if(!$this->form->isActivated($name) || $this->form->isReadonly($name)) continue; 
     501            $this->form->setData($name, $ctrl->getValueFromRequest($request),true); 
    495502        } 
    496503        return $request->getParam($this->ref,''); 
     
    501508    } 
    502509 
    503     function addChildControl($control) { 
     510    function addChildControl($control, $itemName = '') { 
    504511        $this->childControls[$control->ref]=$control; 
    505512    } 
    506513 
    507514    function getChildControls() { return $this->childControls;} 
     515 
     516    function setReadOnly($r){ 
     517        foreach($this->childControls as $name => $ctrl) { 
     518            $this->container->setReadonly($name, $r); 
     519        } 
     520    } 
     521 
     522    function deactivate($r){ 
     523        foreach($this->childControls as $name => $ctrl) { 
     524            $this->container->deactivate($name, $r); 
     525        } 
     526    } 
    508527} 
    509528 
     
    517536} 
    518537 
    519  
    520  
    521538/** 
    522539 * choice 
     
    526543class jFormsControlChoice extends jFormsControlGroups { 
    527544    public $type="choice"; 
    528 
    529  
     545 
     546    public $items = array(); 
     547 
     548 
     549    function addChildControl($control, $itemName = '') { 
     550        $this->childControls[$control->ref]=$control; 
     551        $this->items[$itemName][$control->ref] = $control; 
     552    } 
     553 
     554    function getValueFromRequest($request) { 
     555        $value = $request->getParam($this->ref,''); 
     556 
     557        foreach($this->items as $item => $list) { 
     558            if($item == $value) { 
     559                foreach($list as $ref=>$ctrl) { 
     560                    $this->form->setReadonly($ref, false); 
     561                    $this->form->setData($name, $ctrl->getValueFromRequest($request),true); 
     562                } 
     563            } else { 
     564                foreach($list as $ref=>$ctrl) { 
     565                    $this->form->setReadonly($ref); 
     566                } 
     567            } 
     568        } 
     569        return $value; 
     570    } 
     571
     572 
     573/** 
     574 * choice 
     575 * @package     jelix 
     576 * @subpackage  forms 
     577 */ 
     578class jFormsControlSwitch extends jFormsControlChoice { 
     579    public $type="switch"; 
     580
     581 
     582/** 
     583 * choice 
     584 * @package     jelix 
     585 * @subpackage  forms 
     586 */ 
     587class jFormsControlRepeat extends jFormsControlGroups { 
     588    public $type="repeat"; 
     589
     590 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r910 r911  
    2929    public $alertRequired=''; 
    3030 
     31    protected $form; 
     32    protected $container; 
     33 
     34 
    3135    function __construct($ref){ 
    3236        $this->ref = $ref; 
    3337        $this->datatype = new jDatatypeString(); 
     38    } 
     39 
     40    function setForm($form) { 
     41        $this->form = $form; 
     42        $this->container = $form->getContainer(); 
    3443    } 
    3544 
     
    4150    } 
    4251 
    43     function check($form){ 
    44         $value = $form->getContainer()->data[$this->ref]; 
     52    function check(){ 
     53        $value = $this->form->getContainer()->data[$this->ref]; 
    4554        if($value == '') { 
    4655            if($this->required) 
     
    4958            return jForms::ERRDATA_INVALID; 
    5059        }elseif($this->datatype instanceof jIFilteredDatatype) { 
    51             $form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 
     60            $this->form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 
    5261        } 
    5362        return null; 
     
    5867    } 
    5968 
    60     function getValueFromRequest($form, $request) { 
     69    function getValueFromRequest($request) { 
    6170        return $request->getParam($this->ref,''); 
    6271    } 
     
    136145    public $size=0; 
    137146 
    138     function check($form){ 
    139         if ($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     147    function check(){ 
     148        if ($this->form->getContainer()->data[$this->ref] == '' && $this->required) { 
    140149            return jForms::ERRDATA_REQUIRED; 
    141150        } 
     
    157166    public $primarySecret=''; 
    158167 
    159     function check($form){ 
    160         if($form->getContainer()->data[$this->ref] != $form->getData($this->primarySecret)) 
     168    function check(){ 
     169        if($this->container->data[$this->ref] != $this->form->getData($this->primarySecret)) 
    161170            return jForms::ERRDATA_INVALID; 
    162171        return null; 
     
    175184    public $valueOnUncheck='0'; 
    176185 
    177     function check($form){ 
    178         $value = $form->getContainer()->data[$this->ref]; 
     186    function check(){ 
     187        $value = $this->container->data[$this->ref]; 
    179188        if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 
    180189            return jForms::ERRDATA_INVALID; 
     
    182191    } 
    183192 
    184     function getValueFromRequest($form, $request) { 
     193    function getValueFromRequest($request) { 
    185194        $value = $request->getParam($this->ref); 
    186195        if($value){ 
     
    212221    public $type='output'; 
    213222 
    214     public function check($form){ 
     223    public function check(){ 
    215224        return null; 
    216225    } 
     
    229238    public $fileInfo = array(); 
    230239 
    231     function check($form){ 
     240    function check(){ 
    232241        if(isset($_FILES[$this->ref])) 
    233242            $this->fileInfo = $_FILES[$this->ref]; 
     
    256265    } 
    257266 
    258     function getValueFromRequest($form, $request) { 
     267    function getValueFromRequest($request) { 
    259268        if(isset($_FILES[$this->ref])){ 
    260269            return $_FILES[$this->ref]['name']; 
     
    277286    } 
    278287 
    279     function getValueFromRequest($form, $request) { 
     288    function getValueFromRequest($request) { 
    280289 
    281290        $value = $request->getParam($this->ref,''); 
     
    305314class jFormsControlReset extends jFormsControl { 
    306315    public $type='reset'; 
    307     public function check($form){ 
     316    public function check(){ 
    308317        return null; 
    309318    } 
     
    329338    public $question=''; 
    330339    public $required = true; 
    331     function check($form){ 
    332         $value = $form->getContainer()->data[$this->ref]; 
     340    function check(){ 
     341        $value = $this->container->data[$this->ref]; 
    333342        if($value == '') { 
    334343            return jForms::ERRDATA_REQUIRED; 
    335         }elseif($value != $form->getContainer()->privateData[$this->ref]){ 
     344        }elseif($value != $this->container->privateData[$this->ref]){ 
    336345            return jForms::ERRDATA_INVALID; 
    337346        } 
     
    339348    } 
    340349 
    341     function initExpectedValue($form){ 
     350    function initExpectedValue(){ 
    342351        $numbers = jLocale::get('jelix~captcha.number'); 
    343352        $id = rand(1,intval($numbers)); 
    344353        $this->question = jLocale::get('jelix~captcha.question.'.$id); 
    345         $form->getContainer()->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 
     354        $this->container->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 
    346355    } 
    347356} 
     
    387396    } 
    388397 
    389     function check($form){ 
    390         $value = $form->getContainer()->data[$this->ref]; 
     398    function check(){ 
     399        $value = $this->container->data[$this->ref]; 
    391400        if(is_array($value)){ 
    392401            if(count($value) == 0 && $this->required){ 
     
    419428    } 
    420429 
    421     function check($form){ 
    422         $value = $form->getContainer()->data[$this->ref]; 
     430    function check(){ 
     431        $value = $this->container->data[$this->ref]; 
    423432        if(is_array($value)){ 
    424433            if(!$this->multiple){ 
     
    445454    public $type="radiobuttons"; 
    446455 
    447     function check($form){ 
    448         if($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     456    function check(){ 
     457        if($this->container->data[$this->ref] == '' && $this->required) { 
    449458            return jForms::ERRDATA_REQUIRED; 
    450459        } 
     
    473482    protected $childControls = array(); 
    474483 
    475     function check($form){ 
    476         $check = parent::check($form); 
    477         $container = $form->getContainer(); 
     484    function check(){ 
     485        $check = parent::check(); 
    478486        foreach($this->childControls as $name => $ctrl) { 
    479487            $err = $ctrl->check($this); 
    480488            if($err !== null) 
    481                 $container->errors[$name]= $err; 
     489                $this->container->errors[$name]= $err; 
    482490        } 
    483491        return $check; 
     
    488496    } 
    489497 
    490     function getValueFromRequest($form, $request) { 
    491         $container = $form->getContainer(); 
     498    function getValueFromRequest($request) { 
    492499        foreach($this->childControls as $name => $ctrl) { 
    493             if(!$container->isActivated($name) || $container->isReadonly($name)) continue; 
    494             $form->setData($name, $ctrl->getValueFromRequest($form, $request),true); 
     500            if(!$this->form->isActivated($name) || $this->form->isReadonly($name)) continue; 
     501            $this->form->setData($name, $ctrl->getValueFromRequest($request),true); 
    495502        } 
    496503        return $request->getParam($this->ref,''); 
     
    501508    } 
    502509 
    503     function addChildControl($control) { 
     510    function addChildControl($control, $itemName = '') { 
    504511        $this->childControls[$control->ref]=$control; 
    505512    } 
    506513 
    507514    function getChildControls() { return $this->childControls;} 
     515 
     516    function setReadOnly($r){ 
     517        foreach($this->childControls as $name => $ctrl) { 
     518            $this->container->setReadonly($name, $r); 
     519        } 
     520    } 
     521 
     522    function deactivate($r){ 
     523        foreach($this->childControls as $name => $ctrl) { 
     524            $this->container->deactivate($name, $r); 
     525        } 
     526    } 
    508527} 
    509528 
     
    517536} 
    518537 
    519  
    520  
    521538/** 
    522539 * choice 
     
    526543class jFormsControlChoice extends jFormsControlGroups { 
    527544    public $type="choice"; 
    528 
    529  
     545 
     546    public $items = array(); 
     547 
     548 
     549    function addChildControl($control, $itemName = '') { 
     550        $this->childControls[$control->ref]=$control; 
     551        $this->items[$itemName][$control->ref] = $control; 
     552    } 
     553 
     554    function getValueFromRequest($request) { 
     555        $value = $request->getParam($this->ref,''); 
     556 
     557        foreach($this->items as $item => $list) { 
     558            if($item == $value) { 
     559                foreach($list as $ref=>$ctrl) { 
     560                    $this->form->setReadonly($ref, false); 
     561                    $this->form->setData($name, $ctrl->getValueFromRequest($request),true); 
     562                } 
     563            } else { 
     564                foreach($list as $ref=>$ctrl) { 
     565                    $this->form->setReadonly($ref); 
     566                } 
     567            } 
     568        } 
     569        return $value; 
     570    } 
     571
     572 
     573/** 
     574 * choice 
     575 * @package     jelix 
     576 * @subpackage  forms 
     577 */ 
     578class jFormsControlSwitch extends jFormsControlChoice { 
     579    public $type="switch"; 
     580
     581 
     582/** 
     583 * choice 
     584 * @package     jelix 
     585 * @subpackage  forms 
     586 */ 
     587class jFormsControlRepeat extends jFormsControlGroups { 
     588    public $type="repeat"; 
     589
     590 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r910 r911  
    2929    public $alertRequired=''; 
    3030 
     31    protected $form; 
     32    protected $container; 
     33 
     34 
    3135    function __construct($ref){ 
    3236        $this->ref = $ref; 
    3337        $this->datatype = new jDatatypeString(); 
     38    } 
     39 
     40    function setForm($form) { 
     41        $this->form = $form; 
     42        $this->container = $form->getContainer(); 
    3443    } 
    3544 
     
    4150    } 
    4251 
    43     function check($form){ 
    44         $value = $form->getContainer()->data[$this->ref]; 
     52    function check(){ 
     53        $value = $this->form->getContainer()->data[$this->ref]; 
    4554        if($value == '') { 
    4655            if($this->required) 
     
    4958            return jForms::ERRDATA_INVALID; 
    5059        }elseif($this->datatype instanceof jIFilteredDatatype) { 
    51             $form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 
     60            $this->form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 
    5261        } 
    5362        return null; 
     
    5867    } 
    5968 
    60     function getValueFromRequest($form, $request) { 
     69    function getValueFromRequest($request) { 
    6170        return $request->getParam($this->ref,''); 
    6271    } 
     
    136145    public $size=0; 
    137146 
    138     function check($form){ 
    139         if ($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     147    function check(){ 
     148        if ($this->form->getContainer()->data[$this->ref] == '' && $this->required) { 
    140149            return jForms::ERRDATA_REQUIRED; 
    141150        } 
     
    157166    public $primarySecret=''; 
    158167 
    159     function check($form){ 
    160         if($form->getContainer()->data[$this->ref] != $form->getData($this->primarySecret)) 
     168    function check(){ 
     169        if($this->container->data[$this->ref] != $this->form->getData($this->primarySecret)) 
    161170            return jForms::ERRDATA_INVALID; 
    162171        return null; 
     
    175184    public $valueOnUncheck='0'; 
    176185 
    177     function check($form){ 
    178         $value = $form->getContainer()->data[$this->ref]; 
     186    function check(){ 
     187        $value = $this->container->data[$this->ref]; 
    179188        if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 
    180189            return jForms::ERRDATA_INVALID; 
     
    182191    } 
    183192 
    184     function getValueFromRequest($form, $request) { 
     193    function getValueFromRequest($request) { 
    185194        $value = $request->getParam($this->ref); 
    186195        if($value){ 
     
    212221    public $type='output'; 
    213222 
    214     public function check($form){ 
     223    public function check(){ 
    215224        return null; 
    216225    } 
     
    229238    public $fileInfo = array(); 
    230239 
    231     function check($form){ 
     240    function check(){ 
    232241        if(isset($_FILES[$this->ref])) 
    233242            $this->fileInfo = $_FILES[$this->ref]; 
     
    256265    } 
    257266 
    258     function getValueFromRequest($form, $request) { 
     267    function getValueFromRequest($request) { 
    259268        if(isset($_FILES[$this->ref])){ 
    260269            return $_FILES[$this->ref]['name']; 
     
    277286    } 
    278287 
    279     function getValueFromRequest($form, $request) { 
     288    function getValueFromRequest($request) { 
    280289 
    281290        $value = $request->getParam($this->ref,''); 
     
    305314class jFormsControlReset extends jFormsControl { 
    306315    public $type='reset'; 
    307     public function check($form){ 
     316    public function check(){ 
    308317        return null; 
    309318    } 
     
    329338    public $question=''; 
    330339    public $required = true; 
    331     function check($form){ 
    332         $value = $form->getContainer()->data[$this->ref]; 
     340    function check(){ 
     341        $value = $this->container->data[$this->ref]; 
    333342        if($value == '') { 
    334343            return jForms::ERRDATA_REQUIRED; 
    335         }elseif($value != $form->getContainer()->privateData[$this->ref]){ 
     344        }elseif($value != $this->container->privateData[$this->ref]){ 
    336345            return jForms::ERRDATA_INVALID; 
    337346        } 
     
    339348    } 
    340349 
    341     function initExpectedValue($form){ 
     350    function initExpectedValue(){ 
    342351        $numbers = jLocale::get('jelix~captcha.number'); 
    343352        $id = rand(1,intval($numbers)); 
    344353        $this->question = jLocale::get('jelix~captcha.question.'.$id); 
    345         $form->getContainer()->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 
     354        $this->container->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 
    346355    } 
    347356} 
     
    387396    } 
    388397 
    389     function check($form){ 
    390         $value = $form->getContainer()->data[$this->ref]; 
     398    function check(){ 
     399        $value = $this->container->data[$this->ref]; 
    391400        if(is_array($value)){ 
    392401            if(count($value) == 0 && $this->required){ 
     
    419428    } 
    420429 
    421     function check($form){ 
    422         $value = $form->getContainer()->data[$this->ref]; 
     430    function check(){ 
     431        $value = $this->container->data[$this->ref]; 
    423432        if(is_array($value)){ 
    424433            if(!$this->multiple){ 
     
    445454    public $type="radiobuttons"; 
    446455 
    447     function check($form){ 
    448         if($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     456    function check(){ 
     457        if($this->container->data[$this->ref] == '' && $this->required) { 
    449458            return jForms::ERRDATA_REQUIRED; 
    450459        } 
     
    473482    protected $childControls = array(); 
    474483 
    475     function check($form){ 
    476         $check = parent::check($form); 
    477         $container = $form->getContainer(); 
     484    function check(){ 
     485        $check = parent::check(); 
    478486        foreach($this->childControls as $name => $ctrl) { 
    479487            $err = $ctrl->check($this); 
    480488            if($err !== null) 
    481                 $container->errors[$name]= $err; 
     489                $this->container->errors[$name]= $err; 
    482490        } 
    483491        return $check; 
     
    488496    } 
    489497 
    490     function getValueFromRequest($form, $request) { 
    491         $container = $form->getContainer(); 
     498    function getValueFromRequest($request) { 
    492499        foreach($this->childControls as $name => $ctrl) { 
    493             if(!$container->isActivated($name) || $container->isReadonly($name)) continue; 
    494             $form->setData($name, $ctrl->getValueFromRequest($form, $request),true); 
     500