Changeset 910
- Timestamp:
- 04/28/08 15:51:17 (3 months ago)
- Files:
-
- branches/experimental/jforms-groups/forms.txt (added)
- branches/experimental/jforms-groups/forms.txt (added)
- branches/experimental/jforms-groups/forms.txt (added)
- branches/experimental/jforms-groups/forms.txt (added)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (11 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (11 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (11 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (11 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (7 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (7 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (7 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (7 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 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)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r906 r910 43 43 44 44 /** 45 * List of top controls 46 * array of jFormsControl objects 47 * @var array 48 * @see jFormsControl 49 */ 50 protected $_topControls = array(); 51 52 /** 45 53 * List of submit buttons 46 54 * array of jFormsControl objects … … 86 94 * @var jFormsDataContainer 87 95 */ 88 protected $_container=null; 89 90 /** 91 * says if the form is readonly 92 * @var boolean 93 */ 94 protected $_readOnly = false; 96 protected $_container = null; 95 97 96 98 /** … … 102 104 /** 103 105 * list of modified controls 104 * @var array 106 * keys are name of control, value is the old value of the control 107 * @var array 105 108 */ 106 109 protected $_modifiedControls = array(); … … 131 134 $req = $GLOBALS['gJCoord']->request; 132 135 $this->_modifiedControls=array(); 133 foreach($this->_ controls as $name=>$ctrl){134 if(!$this->_container->isActivated($name) )136 foreach($this->_topControls as $name=>$ctrl){ 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 135 138 continue; 136 $value = $req->getParam($name); 137 138 //@todo à prevoir un meilleur test, pour les formulaires sur plusieurs pages 139 if($value === null) $value=''; 140 141 $value = $ctrl->getValueFromRequest($this, $value); 142 143 if($this->_container->data[$name] != $value) 144 $this->_modifiedControls[$name] = $this->_container->data[$name]; 145 $this->_container->data[$name] = $value; 139 $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 146 140 } 147 141 } … … 403 397 404 398 /** 405 * set the form read only or read/write406 * @param boolean $r true if you want read only407 */408 public function setReadOnly($r = true){ $this->_readOnly = $r; }409 410 /**411 399 * return list of errors found during the check 412 400 * @return array … … 429 417 * @param string $value the data value 430 418 */ 431 public function setData($name, $value){419 public function setData($name, $value, $registerInModified = false){ 432 420 if($this->_controls[$name]->type == 'checkbox') { 433 421 if($value != $this->_controls[$name]->valueOnCheck){ … … 438 426 } 439 427 } 428 if($registerInModified && $this->_container->data[$name] != $value) 429 $this->_modifiedControls[$name] = $this->_container->data[$name]; 440 430 $this->_container->data[$name]=$value; 441 431 } … … 473 463 */ 474 464 public function deactivate($name, $deactivation=true) { 475 if($deactivation) { 476 $this->_container->deactivate($name); 477 } 478 else { 479 $this->_container->deactivate($name, false); 480 } 465 $this->_container->deactivate($name, $deactivation); 481 466 } 482 467 … … 489 474 return $this->_container->isActivated($name); 490 475 } 476 477 478 /** 479 * set a control readonly or not 480 * @param boolean $r true if you want read only 481 */ 482 public function setReadOnly($name, $r = true) { 483 $this->_container->setReadOnly($name, $r); 484 } 485 486 /** 487 * check if a control is readonly 488 * @return boolean true if it is readonly 489 */ 490 public function isReadOnly($name) { 491 return $this->_container->isReadOnly($name); 492 } 493 491 494 492 495 /** … … 625 628 } 626 629 627 628 630 /** 629 631 * add a control to the form … … 631 633 */ 632 634 protected function addControl($control){ 635 if(!$subcontrol) { 636 $this->_topControls [$control->ref] = $control; 637 } 638 $this->addChildControl($control); 639 640 if($control instanceof jFormsControlGroups) { 641 foreach($control->getChildControls() as $ctrl) 642 $this->addChildControl($ctrl); 643 } 644 } 645 646 /** 647 * add a control to the form 648 * @param $control jFormsControl 649 */ 650 protected function addChildControl($control){ 633 651 $this->_controls [$control->ref] = $control; 634 652 if($control->type =='submit') branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r906 r910 43 43 44 44 /** 45 * List of top controls 46 * array of jFormsControl objects 47 * @var array 48 * @see jFormsControl 49 */ 50 protected $_topControls = array(); 51 52 /** 45 53 * List of submit buttons 46 54 * array of jFormsControl objects … … 86 94 * @var jFormsDataContainer 87 95 */ 88 protected $_container=null; 89 90 /** 91 * says if the form is readonly 92 * @var boolean 93 */ 94 protected $_readOnly = false; 96 protected $_container = null; 95 97 96 98 /** … … 102 104 /** 103 105 * list of modified controls 104 * @var array 106 * keys are name of control, value is the old value of the control 107 * @var array 105 108 */ 106 109 protected $_modifiedControls = array(); … … 131 134 $req = $GLOBALS['gJCoord']->request; 132 135 $this->_modifiedControls=array(); 133 foreach($this->_ controls as $name=>$ctrl){134 if(!$this->_container->isActivated($name) )136 foreach($this->_topControls as $name=>$ctrl){ 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 135 138 continue; 136 $value = $req->getParam($name); 137 138 //@todo à prevoir un meilleur test, pour les formulaires sur plusieurs pages 139 if($value === null) $value=''; 140 141 $value = $ctrl->getValueFromRequest($this, $value); 142 143 if($this->_container->data[$name] != $value) 144 $this->_modifiedControls[$name] = $this->_container->data[$name]; 145 $this->_container->data[$name] = $value; 139 $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 146 140 } 147 141 } … … 403 397 404 398 /** 405 * set the form read only or read/write406 * @param boolean $r true if you want read only407 */408 public function setReadOnly($r = true){ $this->_readOnly = $r; }409 410 /**411 399 * return list of errors found during the check 412 400 * @return array … … 429 417 * @param string $value the data value 430 418 */ 431 public function setData($name, $value){419 public function setData($name, $value, $registerInModified = false){ 432 420 if($this->_controls[$name]->type == 'checkbox') { 433 421 if($value != $this->_controls[$name]->valueOnCheck){ … … 438 426 } 439 427 } 428 if($registerInModified && $this->_container->data[$name] != $value) 429 $this->_modifiedControls[$name] = $this->_container->data[$name]; 440 430 $this->_container->data[$name]=$value; 441 431 } … … 473 463 */ 474 464 public function deactivate($name, $deactivation=true) { 475 if($deactivation) { 476 $this->_container->deactivate($name); 477 } 478 else { 479 $this->_container->deactivate($name, false); 480 } 465 $this->_container->deactivate($name, $deactivation); 481 466 } 482 467 … … 489 474 return $this->_container->isActivated($name); 490 475 } 476 477 478 /** 479 * set a control readonly or not 480 * @param boolean $r true if you want read only 481 */ 482 public function setReadOnly($name, $r = true) { 483 $this->_container->setReadOnly($name, $r); 484 } 485 486 /** 487 * check if a control is readonly 488 * @return boolean true if it is readonly 489 */ 490 public function isReadOnly($name) { 491 return $this->_container->isReadOnly($name); 492 } 493 491 494 492 495 /** … … 625 628 } 626 629 627 628 630 /** 629 631 * add a control to the form … … 631 633 */ 632 634 protected function addControl($control){ 635 if(!$subcontrol) { 636 $this->_topControls [$control->ref] = $control; 637 } 638 $this->addChildControl($control); 639 640 if($control instanceof jFormsControlGroups) { 641 foreach($control->getChildControls() as $ctrl) 642 $this->addChildControl($ctrl); 643 } 644 } 645 646 /** 647 * add a control to the form 648 * @param $control jFormsControl 649 */ 650 protected function addChildControl($control){ 633 651 $this->_controls [$control->ref] = $control; 634 652 if($control->type =='submit') branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r906 r910 43 43 44 44 /** 45 * List of top controls 46 * array of jFormsControl objects 47 * @var array 48 * @see jFormsControl 49 */ 50 protected $_topControls = array(); 51 52 /** 45 53 * List of submit buttons 46 54 * array of jFormsControl objects … … 86 94 * @var jFormsDataContainer 87 95 */ 88 protected $_container=null; 89 90 /** 91 * says if the form is readonly 92 * @var boolean 93 */ 94 protected $_readOnly = false; 96 protected $_container = null; 95 97 96 98 /** … … 102 104 /** 103 105 * list of modified controls 104 * @var array 106 * keys are name of control, value is the old value of the control 107 * @var array 105 108 */ 106 109 protected $_modifiedControls = array(); … … 131 134 $req = $GLOBALS['gJCoord']->request; 132 135 $this->_modifiedControls=array(); 133 foreach($this->_ controls as $name=>$ctrl){134 if(!$this->_container->isActivated($name) )136 foreach($this->_topControls as $name=>$ctrl){ 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 135 138 continue; 136 $value = $req->getParam($name); 137 138 //@todo à prevoir un meilleur test, pour les formulaires sur plusieurs pages 139 if($value === null) $value=''; 140 141 $value = $ctrl->getValueFromRequest($this, $value); 142 143 if($this->_container->data[$name] != $value) 144 $this->_modifiedControls[$name] = $this->_container->data[$name]; 145 $this->_container->data[$name] = $value; 139 $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 146 140 } 147 141 } … … 403 397 404 398 /** 405 * set the form read only or read/write406 * @param boolean $r true if you want read only407 */408 public function setReadOnly($r = true){ $this->_readOnly = $r; }409 410 /**411 399 * return list of errors found during the check 412 400 * @return array … … 429 417 * @param string $value the data value 430 418 */ 431 public function setData($name, $value){419 public function setData($name, $value, $registerInModified = false){ 432 420 if($this->_controls[$name]->type == 'checkbox') { 433 421 if($value != $this->_controls[$name]->valueOnCheck){ … … 438 426 } 439 427 } 428 if($registerInModified && $this->_container->data[$name] != $value) 429 $this->_modifiedControls[$name] = $this->_container->data[$name]; 440 430 $this->_container->data[$name]=$value; 441 431 } … … 473 463 */ 474 464 public function deactivate($name, $deactivation=true) { 475 if($deactivation) { 476 $this->_container->deactivate($name); 477 } 478 else { 479 $this->_container->deactivate($name, false); 480 } 465 $this->_container->deactivate($name, $deactivation); 481 466 } 482 467 … … 489 474 return $this->_container->isActivated($name); 490 475 } 476 477 478 /** 479 * set a control readonly or not 480 * @param boolean $r true if you want read only 481 */ 482 public function setReadOnly($name, $r = true) { 483 $this->_container->setReadOnly($name, $r); 484 } 485 486 /** 487 * check if a control is readonly 488 * @return boolean true if it is readonly 489 */ 490 public function isReadOnly($name) { 491 return $this->_container->isReadOnly($name); 492 } 493 491 494 492 495 /** … … 625 628 } 626 629 627 628 630 /** 629 631 * add a control to the form … … 631 633 */ 632 634 protected function addControl($control){ 635 if(!$subcontrol) { 636 $this->_topControls [$control->ref] = $control; 637 } 638 $this->addChildControl($control); 639 640 if($control instanceof jFormsControlGroups) { 641 foreach($control->getChildControls() as $ctrl) 642 $this->addChildControl($ctrl); 643 } 644 } 645 646 /** 647 * add a control to the form 648 * @param $control jFormsControl 649 */ 650 protected function addChildControl($control){ 633 651 $this->_controls [$control->ref] = $control; 634 652 if($control->type =='submit') branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r906 r910 43 43 44 44 /** 45 * List of top controls 46 * array of jFormsControl objects 47 * @var array 48 * @see jFormsControl 49 */ 50 protected $_topControls = array(); 51 52 /** 45 53 * List of submit buttons 46 54 * array of jFormsControl objects … … 86 94 * @var jFormsDataContainer 87 95 */ 88 protected $_container=null; 89 90 /** 91 * says if the form is readonly 92 * @var boolean 93 */ 94 protected $_readOnly = false; 96 protected $_container = null; 95 97 96 98 /** … … 102 104 /** 103 105 * list of modified controls 104 * @var array 106 * keys are name of control, value is the old value of the control 107 * @var array 105 108 */ 106 109 protected $_modifiedControls = array(); … … 131 134 $req = $GLOBALS['gJCoord']->request; 132 135 $this->_modifiedControls=array(); 133 foreach($this->_ controls as $name=>$ctrl){134 if(!$this->_container->isActivated($name) )136 foreach($this->_topControls as $name=>$ctrl){ 137 if(!$this->_container->isActivated($name) || $this->_container->isReadonly($name)) 135 138 continue; 136 $value = $req->getParam($name); 137 138 //@todo à prevoir un meilleur test, pour les formulaires sur plusieurs pages 139 if($value === null) $value=''; 140 141 $value = $ctrl->getValueFromRequest($this, $value); 142 143 if($this->_container->data[$name] != $value) 144 $this->_modifiedControls[$name] = $this->_container->data[$name]; 145 $this->_container->data[$name] = $value; 139 $this->setData($name, $ctrl->getValueFromRequest($this, $req), true); 146 140 } 147 141 } … … 403 397 404 398 /** 405 * set the form read only or read/write406 * @param boolean $r true if you want read only407 */408 public function setReadOnly($r = true){ $this->_readOnly = $r; }409 410 /**411 399 * return list of errors found during the check 412 400 * @return array … … 429 417 * @param string $value the data value 430 418 */ 431 public function setData($name, $value){419 public function setData($name, $value, $registerInModified = false){ 432 420 if($this->_controls[$name]->type == 'checkbox') { 433 421 if($value != $this->_controls[$name]->valueOnCheck){ … … 438 426 } 439 427 } 428 if($registerInModified && $this->_container->data[$name] != $value) 429 $this->_modifiedControls[$name] = $this->_container->data[$name]; 440 430 $this->_container->data[$name]=$value; 441 431 } … … 473 463 */ 474 464 public function deactivate($name, $deactivation=true) { 475 if($deactivation) { 476 $this->_container->deactivate($name); 477 } 478 else { 479 $this->_container->deactivate($name, false); 480 } 465 $this->_container->deactivate($name, $deactivation); 481 466 } 482 467 … … 489 474 return $this->_container->isActivated($name); 490 475 } 476 477 478 /** 479 * set a control readonly or not 480 * @param boolean $r true if you want read only 481 */ 482 public function setReadOnly($name, $r = true) { 483 $this->_container->setReadOnly($name, $r); 484 } 485 486 /** 487 * check if a control is readonly 488 * @return boolean true if it is readonly 489 */ 490 public function isReadOnly($name) { 491 return $this->_container->isReadOnly($name); 492 } 493 491 494 492 495 /** … … 625 628 } 626 629 627 628 630 /** 629 631 * add a control to the form … … 631 633 */ 632 634 protected function addControl($control){ 635 if(!$subcontrol) { 636 $this->_topControls [$control->ref] = $control; 637 } 638 $this->addChildControl($control); 639 640 if($control instanceof jFormsControlGroups) { 641 foreach($control->getChildControls() as $ctrl) 642 $this->addChildControl($ctrl); 643 } 644 } 645 646 /** 647 * add a control to the form 648 * @param $control jFormsControl 649 */ 650 protected function addChildControl($control){ 633 651 $this->_controls [$control->ref] = $control; 634 652 if($control->type =='submit') branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r907 r910 299 299 if(isset($attributes['readonly'])){ 300 300 if('true' == $attributes['readonly']) 301 $source[]='$ ctrl->readonly=true;';301 $source[]='$form->setReadonly($ctrl->ref,true);'; 302 302 unset($attributes['readonly']); 303 303 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r907 r910 299 299 if(isset($attributes['readonly'])){ 300 300 if('true' == $attributes['readonly']) 301 $source[]='$ ctrl->readonly=true;';301 $source[]='$form->setReadonly($ctrl->ref,true);'; 302 302 unset($attributes['readonly']); 303 303 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r907 r910 299 299 if(isset($attributes['readonly'])){ 300 300 if('true' == $attributes['readonly']) 301 $source[]='$ ctrl->readonly=true;';301 $source[]='$form->setReadonly($ctrl->ref,true);'; 302 302 unset($attributes['readonly']); 303 303 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r907 r910 299 299 if(isset($attributes['readonly'])){ 300 300 if('true' == $attributes['readonly']) 301 $source[]='$ ctrl->readonly=true;';301 $source[]='$form->setReadonly($ctrl->ref,true);'; 302 302 unset($attributes['readonly']); 303 303 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r906 r910 34 34 } 35 35 36 /** 37 * says if the control can have multiple values 38 */ 36 39 function isContainer(){ 37 40 return false; … … 55 58 } 56 59 57 function getValueFromRequest($form, $request Value) {58 return $request Value;60 function getValueFromRequest($form, $request) { 61 return $request->getParam($this->ref,''); 59 62 } 60 63 … … 93 96 return $value; 94 97 } 95 96 97 98 } 98 99 … … 181 182 } 182 183 183 function getValueFromRequest($form, $requestValue) { 184 if($requestValue){ 185 return $this->valueOnCheck; 184 function getValueFromRequest($form, $request) { 185 $value = $request->getParam($this->ref); 186 if($value){ 187 return $this->valueOnCheck; 186 188 }else{ 187 189 return $this->valueOnUncheck; … … 254 256 } 255 257 256 function getValueFromRequest($form, $request Value) {258 function getValueFromRequest($form, $request) { 257 259 if(isset($_FILES[$this->ref])){ 258 260 return $_FILES[$this->ref]['name']; … … 275 277 } 276 278 277 function getValueFromRequest($form, $requestValue) { 278 279 if($requestValue && !$this->standalone) { 279 function getValueFromRequest($form, $request) { 280 281 $value = $request->getParam($this->ref,''); 282 283 if($value && !$this->standalone) { 280 284 // because IE send the <button> content as value instead of the content of the 281 285 // "value" attribute, we should verify it and get the real value 282 // or when using <input type="submit">, we have only the label as value (in all browsers... 286 // or when using <input type="submit">, we have only the label as value (in all browsers...) 283 287 $data = $this->datasource->getData($form); 284 if(!isset($data[$ requestValue])) {288 if(!isset($data[$value])) { 285 289 $data=array_flip($data); 286 if(isset($data[$ requestValue])) {287 $ requestValue = $data[$requestValue];290 if(isset($data[$value])) { 291 $value = $data[$value]; 288 292 } 289 293 } 290 294 } 291 return $ requestValue;295 return $value; 292 296 } 293 297 … … 459 463 460 464 465 /** 466 * abstract classes for controls which contain other controls 467 * @package jelix 468 * @subpackage forms 469 */ 470 abstract class jFormsControlGroups extends jFormsControl { 471 public $type = 'groups'; 472 473 protected $childControls = array(); 474 475 function check($form){ 476 $check = parent::check($form); 477 $container = $form->getContainer(); 478 foreach($this->childControls as $name => $ctrl) { 479 $err = $ctrl->check($this); 480 if($err !== null) 481 $container->errors[$name]= $err; 482 } 483 return $check; 484 } 485 486 function getDisplayValue($value){ 487 return $value; 488 } 489 490 function getValueFromRequest($form, $request) { 491 $container = $form->getContainer(); 492 foreach($this->childControls as $name => $ctrl) { 493 if(!$container->isActivated($name) || $container->isReadonly($name)) continue; 494 $form->setData($name, $ctrl->getValueFromRequest($form, $request),true); 495 } 496 return $request->getParam($this->ref,''); 497 } 498 499 function prepareValueFromDao($value, $daoDatatype) { 500 return $value; 501 } 502 503 function addChildControl($control) { 504 $this->childControls[$control->ref]=$control; 505 } 506 507 function getChildControls() { return $this->childControls;} 508 } 509 510 /** 511 * choice 512 * @package jelix 513 * @subpackage forms 514 */ 515 class jFormsControlGroup extends jFormsControlGroups { 516 public $type="group"; 517 } 518 519 520 521 /** 522 * choice 523 * @package jelix 524 * @subpackage forms 525 */ 526 class jFormsControlChoice extends jFormsControlGroups { 527 public $type="choice"; 528 } 529 branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r906 r910 34 34 } 35 35 36 /** 37 * says if the control can have multiple values 38 */ 36 39 function isContainer(){ 37 40 return false; … … 55 58 } 56 59 57 function getValueFromRequest($form, $request Value) {58 return $request Value;60 function getValueFromRequest($form, $request) { 61 return $request->getParam($this->ref,''); 59 62 } 60 63 … … 93 96 return $value; 94 97 } 95 96 97 98 } 98 99 … … 181 182 } 182 183 183 function getValueFromRequest($form, $requestValue) { 184 if($requestValue){ 185 return $this->valueOnCheck; 184 function getValueFromRequest($form, $request) { 185 $value = $request->getParam($this->ref); 186 if($value){ 187 return $this->valueOnCheck; 186 188 }else{ 187 189 return $this->valueOnUncheck; … … 254 256 } 255 257 256 function getValueFromRequest($form, $request Value) {258 function getValueFromRequest($form, $request) { 257 259 if(isset($_FILES[$this->ref])){ 258 260 return $_FILES[$this->ref]['name']; … … 275 277 } 276 278 277 function getValueFromRequest($form, $requestValue) { 278 279 if($requestValue && !$this->standalone) { 279 function getValueFromRequest($form, $request) { 280 281 $value = $request->getParam($this->ref,''); 282 283 if($value && !$this->standalone) { 280 284 // because IE send the <button> content as value instead of the content of the 281 285 // "value" attribute, we should verify it and get the real value 282 // or when using <input type="submit">, we have only the label as value (in all browsers... 286 // or when using <input type="submit">, we have only the label as value (in all browsers...) 283 287 $data = $this->datasource->getData($form); 284 if(!isset($data[$ requestValue])) {288 if(!isset($data[$value])) { 285 289 $data=array_flip($data); 286 if(isset($data[$ requestValue])) {287 $ requestValue = $data[$requestValue];290 if(isset($data[$value])) { 291 $value = $data[$value]; 288 292 } 289 293 } 290 294 } 291 return $ requestValue;295 return $value; 292 296 } 293 297 … … 459 463 460 464 465 /** 466 * abstract classes for controls which contain other controls 467 * @package jelix 468 * @subpackage forms 469 */ 470 abstract class jFormsControlGroups extends jFormsControl { 471 public $type = 'groups'; 472 473 protected $childControls = array(); 474 475 function check($form){ 476 $check = parent::check($form); 477 $container = $form->getContainer(); 478 foreach($this->childControls as $name => $ctrl) { 479 $err = $ctrl->check($this); 480 if($err !== null) 481 $container->errors[$name]= $err; 482 } 483 return $check; 484 } 485 486 function getDisplayValue($value){ 487 return $value; 488 } 489 490 function getValueFromRequest($form, $request) { 491 $container = $form->getContainer(); 492 foreach($this->childControls as $name => $ctrl) { 493 if(!$container->isActivated($name) || $container->isReadonly($name)) continue; 494 $form->setData($name, $ctrl->getValueFromRequest($form, $request),true); 495 } 496 return $request->getParam($this->ref,''); 497 } 498 499 function prepareValueFromDao($value, $daoDatatype) { 500 return $value; 501 } 502 503 function addChildControl($control) { 504 $this->childControls[$control->ref]=$control; 505 } 506 507 function getChildControls() { return $this->childControls;} 508 } 509 510 /** 511 * choice 512 * @package jelix 513 * @subpackage forms 514 */ 515 class jFormsControlGroup extends jFormsControlGroups { 516 public $type="group"; 517 } 518 519 520 521 /** 522 * choice 523 * @package jelix 524 * @subpackage forms 525 */ 526 class jFormsControlChoice extends jFormsControlGroups { 527 public $type="choice"; 528 } 529 branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r906 r910 34 34 } 35 35 36 /** 37 * says if the control can have multiple values 38 */&nb
