Zum Inhalt springen

Formhandler - Eigenen Validator integrieren

Erstellt am 24. Dezember 2011 · Noch keine Antworten

Tags: Frage

menak ·

Hallo allerseits,
wie integriert man einen eigenen Validator in Formhandler?
So geht es jedenfalls nicht:

Fiktive Datei heißt path/to/script-dir/Tx_Formhandler_ErrorCheck_TimeIsLater.php

Darin eine Klasse Tx_Formhandler_ErrorCheck_TimeIsLater welche die Klasse Tx_Formhandler_AbstractErrorCheck erweitert. Die Datei Tx_Formhandler_ErrorCheck_TimeIsLater.php wird nicht aufgerufen geschweige denn dass die Klasse verwendet wird.

plugin.Tx_Formhandler.settings.additionalIncludePaths.1 = path/to/script-dir/

plugin.Tx_Formhandler.settings.predef.formname.if.1 {
    conditions.OR1.AND1 = field = value
    isTrue.validators.1.config.fieldConf {
        1.class = Tx_Formhandler_ErrorCheck_TimeIsLater
        1 {
            value = TEXT
            value.data = GP : cform | start_time
        }
    }
}

Und hier die ErrorCheck-Klasse

class Tx_Formhandler_ErrorCheck_TimeIsLater extends Tx_Formhandler_AbstractErrorCheck {

	public function init($gp, $settings) {
		parent::init($gp, $settings);
		$this->mandatoryParameters = array('value');
	}

	public function check() {
		$checkFailed = '';
		$min = strtotime($this->utilityFuncs->getSingle($this->settings['params'], 'value'));
		$valueToCheck = strtotime($this->gp[$this->formFieldName]);
		if (isset($this->gp[$this->formFieldName]) &&
			$valueToCheck >= 0 &&
			$min >= 0 &&
			(!is_numeric($valueToCheck) || $valueToCheck < $min)) {

			$checkFailed = $this->getCheckFailed();
		}
		return $checkFailed;
	}

}

So geht es jedenfalls nicht! #angry#

Vielen Dank im Voraus!