Added example from #207
This commit is contained in:
		
					parent
					
						
							
								b11f5966e6
							
						
					
				
			
			
				commit
				
					
						9039cb66a9
					
				
			
		
					 1 changed files with 18 additions and 0 deletions
				
			
		
							
								
								
									
										18
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
										
									
									
									
								
							|  | @ -766,6 +766,24 @@ Note that the 'inputs' parameter is writable and is an array. The array may cont | |||
| 
 | ||||
| The 'before' function allows modification of the request parameters and can (for instance) be used to implement soft delete behavior. | ||||
| 
 | ||||
| ```php | ||||
| 'before'=>function(&$cmd, &$db, &$tab, &$id, &$in) {  | ||||
| 	if ($cmd == 'delete') { | ||||
| 		$cmd = 'update'; // change command to update | ||||
| 		foreach($in as $k => $o) { | ||||
| 			$in[$k]->deleted = date('Y-m-d H:i:s', time()); | ||||
| 		}				 | ||||
| 	} | ||||
| 			 | ||||
| }, | ||||
| 'column_authorizer'=>function($cmd, $db ,$tab, $col) {  | ||||
| 	return ( ! in_array($col, array('deleted'))); | ||||
| }, | ||||
| 'record_filter'=>function($cmd,$db,$tab) {  | ||||
| 	return array('deleted,is,null'); | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| ## Custom actions | ||||
| 
 | ||||
| After any operation the 'after' function is called that allows you to do some custom actions. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 mevdschee
				mevdschee