Changeset 748
- Timestamp:
- 08/28/08 14:09:27 (3 months ago)
- Files:
-
- trunk/lib/Form.php (modified) (6 diffs)
- trunk/lib/Form/Field.php (modified) (6 diffs)
- trunk/lib/QuickSearch.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/Form.php
r733 r748 112 112 return $this; 113 113 } 114 function denyEnter(){ 115 // prevents the submit on Enter for the last field 116 // apply it when there is only one field on the form 117 $this->last_field->denyEnter(); 118 return $this; 119 } 114 120 function setFieldComment($comment){ 115 121 /** 116 * Adds a comment to the last field. 122 * Adds a comment to the last field. 117 123 * Comment will be inserted to the field_comment tag of the form template 118 124 */ … … 195 201 } 196 202 //if($this->elements[$field_or_array] instanceof Form_Button)echo caller_lookup(0); 197 if($this->elements[$field_or_array] instanceof Form_Field) 203 if($this->elements[$field_or_array] instanceof Form_Field) 198 204 $this->elements[$field_or_array]->set($value); 199 205 else{ … … 239 245 ($msg?$msg:'".$this->caption." is a mandatory field!').'");'); 240 246 return $this; 241 } 242 243 247 } 248 249 244 250 function setNotNull($msg=''){ 245 251 $this->validateNotNULL($msg); … … 268 274 ->setLabel($label) 269 275 ->setNoSave(); 270 if (!is_null($color)) 276 if (!is_null($color)) 271 277 $this->last_field->setColor($color); 272 278 … … 285 291 $field = $this->last_button = $this->add('Form_Button',isset($name)?$name:$label,'form_buttons') 286 292 ->setLabel($label); 287 288 if (!is_null($color)) 293 294 if (!is_null($color)) 289 295 $field->setColor($color); 290 296 291 297 $field->setNoSave(); 292 298 … … 344 350 345 351 346 352 347 353 function submitted(){ 348 354 /** trunk/lib/Form/Field.php
r744 r748 127 127 /* Since all browsers except Opera handle only button cancelling on even onKeyDown and Opera on KeyPress 128 128 Determine whats the browser and put JS in proper event */ 129 (stripos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ? 'onKeyPress' : 'onKeyDown') =>(is_null($this->onkeypress)?' return denyEnter(event);':$this->onkeypress->getString()),129 (stripos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ? 'onKeyPress' : 'onKeyDown') =>(is_null($this->onkeypress)?'':$this->onkeypress->getString()), 130 130 'onfocus'=>(is_null($this->onfocus)?'':$this->onfocus->getString()), 131 131 'onblur'=>(is_null($this->onblur)?'':$this->onblur->getString()), … … 133 133 ),$attr,$this->attr) 134 134 ); 135 } 136 function denyEnter(){ 137 $this->onKeyPress()->ajaxFunc('if(isKeyPressed(e, kReturn))return false'); 138 return $this; 135 139 } 136 140 function setSeparator($separator){ … … 419 423 $this->value_list = $list; 420 424 } 421 function loadPOST(){ 425 function loadPOST(){ 422 426 $data=$_POST[$this->name]; 423 427 if(is_array($data))$data=join(',',$data); … … 441 445 return parent::validate(); 442 446 } 443 function getInput($attr=array()){ 447 function getInput($attr=array()){ 444 448 $output=$this->getTag('select',array_merge(array( 445 449 'name'=>$this->name, … … 460 464 )) 461 465 .htmlspecialchars($descr) 462 .$this->getTag('/option'); 466 .$this->getTag('/option'); 463 467 } else { 464 468 $output.= … … 468 472 )) 469 473 .htmlspecialchars($descr) 470 .$this->getTag('/option'); 474 .$this->getTag('/option'); 471 475 } 472 476 } trunk/lib/QuickSearch.php
r732 r748 15 15 $this->useDQ($this->owner->dq); 16 16 //on field change we should change a name of a button also: 'clear' in the name will clear fields 17 $this->addField('Search','q','Find')-> onChange()->ajaxFunc($this->setGoFunc());17 $this->addField('Search','q','Find')->denyEnter()->onChange()->ajaxFunc($this->setGoFunc()); 18 18 $this->last_field->onKeyPress()->ajaxFunc($this->setGoFunc()); 19 19 $this->addButton('Clear','Clear')->submitForm($this);
