Changeset 911
- Timestamp:
- 04/28/08 20:45:35 (3 months ago)
- Files:
-
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (5 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (5 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (5 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (5 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (23 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (23 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (23 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (23 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r910 r911 137 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 138 138 continue; 139 $this->setData($name, $ctrl->getValueFromRequest($ this, $req), true);139 $this->setData($name, $ctrl->getValueFromRequest($req), true); 140 140 } 141 141 } … … 150 150 if(!$this->_container->isActivated($name)) 151 151 continue; 152 $err = $ctrl->check( $this);152 $err = $ctrl->check(); 153 153 if($err !== null) 154 154 $this->_container->errors[$name]= $err; … … 464 464 public function deactivate($name, $deactivation=true) { 465 465 $this->_container->deactivate($name, $deactivation); 466 if($this->_controls[$name] implements jFormsControlGroups) { 467 $this->_controls[$name]->deactivate($this, $r); 468 } 466 469 } 467 470 … … 482 485 public function setReadOnly($name, $r = true) { 483 486 $this->_container->setReadOnly($name, $r); 487 if($this->_controls[$name] implements jFormsControlGroups) { 488 $this->_controls[$name]->setReadOnly($this, $r); 489 } 484 490 } 485 491 … … 661 667 $this->_htmleditors [$control->ref] = $control; 662 668 669 $control->setForm($this); 670 663 671 if(!isset($this->_container->data[$control->ref])){ 664 672 if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r910 r911 137 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 138 138 continue; 139 $this->setData($name, $ctrl->getValueFromRequest($ this, $req), true);139 $this->setData($name, $ctrl->getValueFromRequest($req), true); 140 140 } 141 141 } … … 150 150 if(!$this->_container->isActivated($name)) 151 151 continue; 152 $err = $ctrl->check( $this);152 $err = $ctrl->check(); 153 153 if($err !== null) 154 154 $this->_container->errors[$name]= $err; … … 464 464 public function deactivate($name, $deactivation=true) { 465 465 $this->_container->deactivate($name, $deactivation); 466 if($this->_controls[$name] implements jFormsControlGroups) { 467 $this->_controls[$name]->deactivate($this, $r); 468 } 466 469 } 467 470 … … 482 485 public function setReadOnly($name, $r = true) { 483 486 $this->_container->setReadOnly($name, $r); 487 if($this->_controls[$name] implements jFormsControlGroups) { 488 $this->_controls[$name]->setReadOnly($this, $r); 489 } 484 490 } 485 491 … … 661 667 $this->_htmleditors [$control->ref] = $control; 662 668 669 $control->setForm($this); 670 663 671 if(!isset($this->_container->data[$control->ref])){ 664 672 if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r910 r911 137 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 138 138 continue; 139 $this->setData($name, $ctrl->getValueFromRequest($ this, $req), true);139 $this->setData($name, $ctrl->getValueFromRequest($req), true); 140 140 } 141 141 } … … 150 150 if(!$this->_container->isActivated($name)) 151 151 continue; 152 $err = $ctrl->check( $this);152 $err = $ctrl->check(); 153 153 if($err !== null) 154 154 $this->_container->errors[$name]= $err; … … 464 464 public function deactivate($name, $deactivation=true) { 465 465 $this->_container->deactivate($name, $deactivation); 466 if($this->_controls[$name] implements jFormsControlGroups) { 467 $this->_controls[$name]->deactivate($this, $r); 468 } 466 469 } 467 470 … … 482 485 public function setReadOnly($name, $r = true) { 483 486 $this->_container->setReadOnly($name, $r); 487 if($this->_controls[$name] implements jFormsControlGroups) { 488 $this->_controls[$name]->setReadOnly($this, $r); 489 } 484 490 } 485 491 … … 661 667 $this->_htmleditors [$control->ref] = $control; 662 668 669 $control->setForm($this); 670 663 671 if(!isset($this->_container->data[$control->ref])){ 664 672 if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r910 r911 137 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 138 138 continue; 139 $this->setData($name, $ctrl->getValueFromRequest($ this, $req), true);139 $this->setData($name, $ctrl->getValueFromRequest($req), true); 140 140 } 141 141 } … … 150 150 if(!$this->_container->isActivated($name)) 151 151 continue; 152 $err = $ctrl->check( $this);152 $err = $ctrl->check(); 153 153 if($err !== null) 154 154 $this->_container->errors[$name]= $err; … … 464 464 public function deactivate($name, $deactivation=true) { 465 465 $this->_container->deactivate($name, $deactivation); 466 if($this->_controls[$name] implements jFormsControlGroups) { 467 $this->_controls[$name]->deactivate($this, $r); 468 } 466 469 } 467 470 … … 482 485 public function setReadOnly($name, $r = true) { 483 486 $this->_container->setReadOnly($name, $r); 487 if($this->_controls[$name] implements jFormsControlGroups) { 488 $this->_controls[$name]->setReadOnly($this, $r); 489 } 484 490 } 485 491 … … 661 667 $this->_htmleditors [$control->ref] = $control; 662 668 669 $control->setForm($this); 670 663 671 if(!isset($this->_container->data[$control->ref])){ 664 672 if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r910 r911 29 29 public $alertRequired=''; 30 30 31 protected $form; 32 protected $container; 33 34 31 35 function __construct($ref){ 32 36 $this->ref = $ref; 33 37 $this->datatype = new jDatatypeString(); 38 } 39 40 function setForm($form) { 41 $this->form = $form; 42 $this->container = $form->getContainer(); 34 43 } 35 44 … … 41 50 } 42 51 43 function check( $form){44 $value = $ form->getContainer()->data[$this->ref];52 function check(){ 53 $value = $this->form->getContainer()->data[$this->ref]; 45 54 if($value == '') { 46 55 if($this->required) … … 49 58 return jForms::ERRDATA_INVALID; 50 59 }elseif($this->datatype instanceof jIFilteredDatatype) { 51 $ form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue();60 $this->form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 52 61 } 53 62 return null; … … 58 67 } 59 68 60 function getValueFromRequest($ form, $request) {69 function getValueFromRequest($request) { 61 70 return $request->getParam($this->ref,''); 62 71 } … … 136 145 public $size=0; 137 146 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) { 140 149 return jForms::ERRDATA_REQUIRED; 141 150 } … … 157 166 public $primarySecret=''; 158 167 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)) 161 170 return jForms::ERRDATA_INVALID; 162 171 return null; … … 175 184 public $valueOnUncheck='0'; 176 185 177 function check( $form){178 $value = $ form->getContainer()->data[$this->ref];186 function check(){ 187 $value = $this->container->data[$this->ref]; 179 188 if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 180 189 return jForms::ERRDATA_INVALID; … … 182 191 } 183 192 184 function getValueFromRequest($ form, $request) {193 function getValueFromRequest($request) { 185 194 $value = $request->getParam($this->ref); 186 195 if($value){ … … 212 221 public $type='output'; 213 222 214 public function check( $form){223 public function check(){ 215 224 return null; 216 225 } … … 229 238 public $fileInfo = array(); 230 239 231 function check( $form){240 function check(){ 232 241 if(isset($_FILES[$this->ref])) 233 242 $this->fileInfo = $_FILES[$this->ref]; … … 256 265 } 257 266 258 function getValueFromRequest($ form, $request) {267 function getValueFromRequest($request) { 259 268 if(isset($_FILES[$this->ref])){ 260 269 return $_FILES[$this->ref]['name']; … … 277 286 } 278 287 279 function getValueFromRequest($ form, $request) {288 function getValueFromRequest($request) { 280 289 281 290 $value = $request->getParam($this->ref,''); … … 305 314 class jFormsControlReset extends jFormsControl { 306 315 public $type='reset'; 307 public function check( $form){316 public function check(){ 308 317 return null; 309 318 } … … 329 338 public $question=''; 330 339 public $required = true; 331 function check( $form){332 $value = $ form->getContainer()->data[$this->ref];340 function check(){ 341 $value = $this->container->data[$this->ref]; 333 342 if($value == '') { 334 343 return jForms::ERRDATA_REQUIRED; 335 }elseif($value != $form->getContainer()->privateData[$this->ref]){344 }elseif($value != $this->container->privateData[$this->ref]){ 336 345 return jForms::ERRDATA_INVALID; 337 346 } … … 339 348 } 340 349 341 function initExpectedValue( $form){350 function initExpectedValue(){ 342 351 $numbers = jLocale::get('jelix~captcha.number'); 343 352 $id = rand(1,intval($numbers)); 344 353 $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); 346 355 } 347 356 } … … 387 396 } 388 397 389 function check( $form){390 $value = $ form->getContainer()->data[$this->ref];398 function check(){ 399 $value = $this->container->data[$this->ref]; 391 400 if(is_array($value)){ 392 401 if(count($value) == 0 && $this->required){ … … 419 428 } 420 429 421 function check( $form){422 $value = $ form->getContainer()->data[$this->ref];430 function check(){ 431 $value = $this->container->data[$this->ref]; 423 432 if(is_array($value)){ 424 433 if(!$this->multiple){ … … 445 454 public $type="radiobuttons"; 446 455 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) { 449 458 return jForms::ERRDATA_REQUIRED; 450 459 } … … 473 482 protected $childControls = array(); 474 483 475 function check($form){ 476 $check = parent::check($form); 477 $container = $form->getContainer(); 484 function check(){ 485 $check = parent::check(); 478 486 foreach($this->childControls as $name => $ctrl) { 479 487 $err = $ctrl->check($this); 480 488 if($err !== null) 481 $ container->errors[$name]= $err;489 $this->container->errors[$name]= $err; 482 490 } 483 491 return $check; … … 488 496 } 489 497 490 function getValueFromRequest($form, $request) { 491 $container = $form->getContainer(); 498 function getValueFromRequest($request) { 492 499 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); 495 502 } 496 503 return $request->getParam($this->ref,''); … … 501 508 } 502 509 503 function addChildControl($control ) {510 function addChildControl($control, $itemName = '') { 504 511 $this->childControls[$control->ref]=$control; 505 512 } 506 513 507 514 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 } 508 527 } 509 528 … … 517 536 } 518 537 519 520 521 538 /** 522 539 * choice … … 526 543 class jFormsControlChoice extends jFormsControlGroups { 527 544 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 */ 578 class jFormsControlSwitch extends jFormsControlChoice { 579 public $type="switch"; 580 } 581 582 /** 583 * choice 584 * @package jelix 585 * @subpackage forms 586 */ 587 class jFormsControlRepeat extends jFormsControlGroups { 588 public $type="repeat"; 589 } 590 branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r910 r911 29 29 public $alertRequired=''; 30 30 31 protected $form; 32 protected $container; 33 34 31 35 function __construct($ref){ 32 36 $this->ref = $ref; 33 37 $this->datatype = new jDatatypeString(); 38 } 39 40 function setForm($form) { 41 $this->form = $form; 42 $this->container = $form->getContainer(); 34 43 } 35 44 … … 41 50 } 42 51 43 function check( $form){44 $value = $ form->getContainer()->data[$this->ref];52 function check(){ 53 $value = $this->form->getContainer()->data[$this->ref]; 45 54 if($value == '') { 46 55 if($this->required) … … 49 58 return jForms::ERRDATA_INVALID; 50 59 }elseif($this->datatype instanceof jIFilteredDatatype) { 51 $ form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue();60 $this->form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 52 61 } 53 62 return null; … … 58 67 } 59 68 60 function getValueFromRequest($ form, $request) {69 function getValueFromRequest($request) { 61 70 return $request->getParam($this->ref,''); 62 71 } … … 136 145 public $size=0; 137 146 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) { 140 149 return jForms::ERRDATA_REQUIRED; 141 150 } … … 157 166 public $primarySecret=''; 158 167 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)) 161 170 return jForms::ERRDATA_INVALID; 162 171 return null; … … 175 184 public $valueOnUncheck='0'; 176 185 177 function check( $form){178 $value = $ form->getContainer()->data[$this->ref];186 function check(){ 187 $value = $this->container->data[$this->ref]; 179 188 if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 180 189 return jForms::ERRDATA_INVALID; … … 182 191 } 183 192 184 function getValueFromRequest($ form, $request) {193 function getValueFromRequest($request) { 185 194 $value = $request->getParam($this->ref); 186 195 if($value){ … … 212 221 public $type='output'; 213 222 214 public function check( $form){223 public function check(){ 215 224 return null; 216 225 } … … 229 238 public $fileInfo = array(); 230 239 231 function check( $form){240 function check(){ 232 241 if(isset($_FILES[$this->ref])) 233 242 $this->fileInfo = $_FILES[$this->ref]; … … 256 265 } 257 266 258 function getValueFromRequest($ form, $request) {267 function getValueFromRequest($request) { 259 268 if(isset($_FILES[$this->ref])){ 260 269 return $_FILES[$this->ref]['name']; … … 277 286 } 278 287 279 function getValueFromRequest($ form, $request) {288 function getValueFromRequest($request) { 280 289 281 290 $value = $request->getParam($this->ref,''); … … 305 314 class jFormsControlReset extends jFormsControl { 306 315 public $type='reset'; 307 public function check( $form){316 public function check(){ 308 317 return null; 309 318 } … … 329 338 public $question=''; 330 339 public $required = true; 331 function check( $form){332 $value = $ form->getContainer()->data[$this->ref];340 function check(){ 341 $value = $this->container->data[$this->ref]; 333 342 if($value == '') { 334 343 return jForms::ERRDATA_REQUIRED; 335 }elseif($value != $form->getContainer()->privateData[$this->ref]){344 }elseif($value != $this->container->privateData[$this->ref]){ 336 345 return jForms::ERRDATA_INVALID; 337 346 } … … 339 348 } 340 349 341 function initExpectedValue( $form){350 function initExpectedValue(){ 342 351 $numbers = jLocale::get('jelix~captcha.number'); 343 352 $id = rand(1,intval($numbers)); 344 353 $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); 346 355 } 347 356 } … … 387 396 } 388 397 389 function check( $form){390 $value = $ form->getContainer()->data[$this->ref];398 function check(){ 399 $value = $this->container->data[$this->ref]; 391 400 if(is_array($value)){ 392 401 if(count($value) == 0 && $this->required){ … … 419 428 } 420 429 421 function check( $form){422 $value = $ form->getContainer()->data[$this->ref];430 function check(){ 431 $value = $this->container->data[$this->ref]; 423 432 if(is_array($value)){ 424 433 if(!$this->multiple){ … … 445 454 public $type="radiobuttons"; 446 455 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) { 449 458 return jForms::ERRDATA_REQUIRED; 450 459 } … … 473 482 protected $childControls = array(); 474 483 475 function check($form){ 476 $check = parent::check($form); 477 $container = $form->getContainer(); 484 function check(){ 485 $check = parent::check(); 478 486 foreach($this->childControls as $name => $ctrl) { 479 487 $err = $ctrl->check($this); 480 488 if($err !== null) 481 $ container->errors[$name]= $err;489 $this->container->errors[$name]= $err; 482 490 } 483 491 return $check; … … 488 496 } 489 497 490 function getValueFromRequest($form, $request) { 491 $container = $form->getContainer(); 498 function getValueFromRequest($request) { 492 499 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); 495 502 } 496 503 return $request->getParam($this->ref,''); … … 501 508 } 502 509 503 function addChildControl($control ) {510 function addChildControl($control, $itemName = '') { 504 511 $this->childControls[$control->ref]=$control; 505 512 } 506 513 507 514 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 } 508 527 } 509 528 … … 517 536 } 518 537 519 520 521 538 /** 522 539 * choice … … 526 543 class jFormsControlChoice extends jFormsControlGroups { 527 544 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 */ 578 class jFormsControlSwitch extends jFormsControlChoice { 579 public $type="switch"; 580 } 581 582 /** 583 * choice 584 * @package jelix 585 * @subpackage forms 586 */ 587 class jFormsControlRepeat extends jFormsControlGroups { 588 public $type="repeat"; 589 } 590 branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r910 r911 29 29 public $alertRequired=''; 30 30 31 protected $form; 32 protected $container; 33 34 31 35 function __construct($ref){ 32 36 $this->ref = $ref; 33 37 $this->datatype = new jDatatypeString(); 38 } 39 40 function setForm($form) { 41 $this->form = $form; 42 $this->container = $form->getContainer(); 34 43 } 35 44 … … 41 50 } 42 51 43 function check( $form){44 $value = $ form->getContainer()->data[$this->ref];52 function check(){ 53 $value = $this->form->getContainer()->data[$this->ref]; 45 54 if($value == '') { 46 55 if($this->required) … … 49 58 return jForms::ERRDATA_INVALID; 50 59 }elseif($this->datatype instanceof jIFilteredDatatype) { 51 $ form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue();60 $this->form->getContainer()->data[$this->ref] = $this->datatype->getFilteredValue(); 52 61 } 53 62 return null; … … 58 67 } 59 68 60 function getValueFromRequest($ form, $request) {69 function getValueFromRequest($request) { 61 70 return $request->getParam($this->ref,''); 62 71 } … … 136 145 public $size=0; 137 146 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) { 140 149 return jForms::ERRDATA_REQUIRED; 141 150 } … … 157 166 public $primarySecret=''; 158 167 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)) 161 170 return jForms::ERRDATA_INVALID; 162 171 return null; … … 175 184 public $valueOnUncheck='0'; 176 185 177 function check( $form){178 $value = $ form->getContainer()->data[$this->ref];186 function check(){ 187 $value = $this->container->data[$this->ref]; 179 188 if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 180 189 return jForms::ERRDATA_INVALID; … … 182 191 } 183 192 184 function getValueFromRequest($ form, $request) {193 function getValueFromRequest($request) { 185 194 $value = $request->getParam($this->ref); 186 195 if($value){ … … 212 221 public $type='output'; 213 222 214 public function check( $form){223 public function check(){ 215 224 return null; 216 225 } … … 229 238 public $fileInfo = array(); 230 239 231 function check( $form){240 function check(){ 232 241 if(isset($_FILES[$this->ref])) 233 242 $this->fileInfo = $_FILES[$this->ref]; … … 256 265 } 257 266 258 function getValueFromRequest($ form, $request) {267 function getValueFromRequest($request) { 259 268 if(isset($_FILES[$this->ref])){ 260 269 return $_FILES[$this->ref]['name']; … … 277 286 } 278 287 279 function getValueFromRequest($ form, $request) {288 function getValueFromRequest($request) { 280 289 281 290 $value = $request->getParam($this->ref,''); … … 305 314 class jFormsControlReset extends jFormsControl { 306 315 public $type='reset'; 307 public function check( $form){316 public function check(){ 308 317 return null; 309 318 } … … 329 338 public $question=''; 330 339 public $required = true; 331 function check( $form){332 $value = $ form->getContainer()->data[$this->ref];340 function check(){ 341 $value = $this->container->data[$this->ref]; 333 342 if($value == '') { 334 343 return jForms::ERRDATA_REQUIRED; 335 }elseif($value != $form->getContainer()->privateData[$this->ref]){344 }elseif($value != $this->container->privateData[$this->ref]){ 336 345 return jForms::ERRDATA_INVALID; 337 346 } … … 339 348 } 340 349 341 function initExpectedValue( $form){350 function initExpectedValue(){ 342 351 $numbers = jLocale::get('jelix~captcha.number'); 343 352 $id = rand(1,intval($numbers)); 344 353 $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); 346 355 } 347 356 } … … 387 396 } 388 397 389 function check( $form){390 $value = $ form->getContainer()->data[$this->ref];398 function check(){ 399 $value = $this->container->data[$this->ref]; 391 400 if(is_array($value)){ 392 401 if(count($value) == 0 && $this->required){ … … 419 428 } 420 429 421 function check( $form){422 $value = $ form->getContainer()->data[$this->ref];430 function check(){ 431 $value = $this->container->data[$this->ref]; 423 432 if(is_array($value)){ 424 433 if(!$this->multiple){ … … 445 454 public $type="radiobuttons"; 446 455 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) { 449 458 return jForms::ERRDATA_REQUIRED; 450 459 } … … 473 482 protected $childControls = array(); 474 483 475 function check($form){ 476 $check = parent::check($form); 477 $container = $form->getContainer(); 484 function check(){ 485 $check = parent::check(); 478 486 foreach($this->childControls as $name => $ctrl) { 479 487 $err = $ctrl->check($this); 480 488 if($err !== null) 481 $ container->errors[$name]= $err;489 $this->container->errors[$name]= $err; 482 490 } 483 491 return $check; … … 488 496 } 489 497 490 function getValueFromRequest($form, $request) { 491 $container = $form->getContainer(); 498 function getValueFromRequest($request) { 492 499 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
