Location: PHPKode > projects > Adroit > 1.2.1/adroit/templates/Crud.controller.php
<?php
class {controller}Controller extends BaseController {
	
	protected $filters = array(
		array('exclude'=>'delete', 'filter'=>'setCrudProperties')
	);
	
	protected function setCrudProperties() {
		$this->setClassProperties('{model}');
	}
	
	public function indexAction($requestData) {
		$this->data['{object-collection}'] = {model}::getAll();
	}
	
	public function editAction($requestData) {
		if(@$requestData['arg0'] !== '') {
			$this->data['{object-single}'] = {model}::get($requestData['arg0']);
		}else {
			$this->data['{object-single}'] = new {model}(array());
		}
	}
	
	public function saveAction($requestData) {
		$requestData['id'] = $requestData['{object-single}'];
		$object = new {model}($requestData);
		$validation = $object->validate();
		if(is_array($validation)) {
			$this->addValidationErrors($validation);
			$this->data['{object-single}'] = $object;
			BaseController::forward('{controller-route}', 'edit');
		}else {
			if($object->id == '') {
				$object->save();
				Adroit::$alerts->addAlert('{model} has been saved', AdroitAlertHandler::$TYPE_SUCCESS);
			}else {
				$object->update();
				Adroit::$alerts->addAlert('{model} has been updated', AdroitAlertHandler::$TYPE_SUCCESS);
			}
			BaseController::redirect('{controller-route}', 'edit/' . $object->id);
		}
	}
	
	public function deleteAction($requestData) {
		if(@$requestData['{object-single}'] != '') {
			{model}::get($requestData['{object-single}'])->delete();
			Adroit::$alerts->addAlert('{model} deleted', AdroitAlertHandler::$TYPE_SUCCESS);
		}
		BaseController::redirect('{controller-route}/');
	}
}
?>
Return current item: Adroit