     var saveHandler : (()->())?
     var cancelHandler : (()->())?
     
+    var preSaveCheck: ()->CheckResult={
+        return CheckResult(passed: true)
+    }
+
+    var preCancelCheck: ()->CheckResult={
+        return CheckResult(passed: true)
+    }
+
+    
     required init(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
     }

        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Speichern", style: .plain, target: self, action: #selector(GenericFormViewController.save))
            let image=GlyphTools.sharedInstance().getGlyphedImage("icon-chevron-left", fontsize: 11, size: CGSize(width: 14, height: 14))
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: image, style: UIBarButtonItemStyle.plain , target: self, action: #selector(GenericFormViewController.cancel))
        
    }
    
    
    func save() {
        self.dismiss(animated: true) { () -> Void in
            if let sh=self.saveHandler {
                sh()
            }
            else {
                //should not  happen >> log it
            }
        }
    }
    

    
}

class CheckResult {
    var passed: Bool
    var message: String
    var title: String
    
    init(passed: Bool, title:String="", withMessage:String = ""){
        self.passed=passed
        self.title=title
        self.message=withMessage
    }
}

