Changeset 750
- Timestamp:
- 08/30/08 09:51:10 (3 months ago)
- Files:
-
- addons/camper/CmdForm.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
addons/camper/CmdForm.php
r696 r750 8 8 public $section_open=null; // template chunk that opens new section 9 9 public $section_close=null; // template chunk that closes section 10 10 11 11 function init(){ 12 12 // template->get … … 15 15 $this->section_close=$this->template->is_set('section_close')?$this->template->cloneRegion('section_close'): 16 16 $this->template->cloneRegion('form_comment'); // yes, this cloning should be twice in the order like it is 17 // if you comment out one of them, you'll see 17 // if you comment out one of them, you'll see 18 18 $this->template->tryDel('section_open'); 19 19 $this->template->tryDel('section_close'); 20 20 21 21 parent::init(); 22 22 } … … 28 28 return $this; 29 29 } 30 30 31 31 function update(){ 32 32 foreach($this->elements as $short_name=>$element){ 33 if($element instanceof Form_Field && 33 if($element instanceof Form_Field && 34 34 ($element->get()===''||is_null($element->get()))) 35 35 $this->set($short_name,$element->default_value); … … 37 37 return parent::update(); 38 38 } 39 39 40 40 function addField($type,$name,$caption=null,$attr=null){ 41 41 // opening Section if there is no any … … 48 48 function addComment($comment){ 49 49 if(!$this->section_opened)$this->newSection(); 50 50 51 51 return parent::addComment($comment); 52 52 } … … 58 58 /* 59 59 * Opens column/row 60 * 60 * 61 61 */ 62 62 if(!is_object($this->section_open))return $this; … … 100 100 return $data; 101 101 } 102 function validateField($condition,$msg='',$field=null){ 103 if(is_null($field))$field=$this->last_field; 104 if(!is_object($field))$field=$this->getElement($field); 105 $field->addHook('validate','if(!('.$condition.'))$this->displayFieldError("'. 106 ($msg?$msg:'Error in ".$this->caption."').'");'); 107 return $this; 108 } 102 109 103 110 /*function addComment($comment){
