TYPO3 TCA's own score (validation) for a combination of three fields

I have read https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Input.html#eval and try my own estimates.

It should evaluate a combination of three fields with this logic: start_date AND end_date is required (not empty) OR date_on_request is required.

The class is loaded and the functionFieldValue () function works, but I am missing the feedback on the form.

<?php
namespace Vendor\Extension\Evaluation;

class StartDateAndEndDateOrDateOnRequestEvaluation {

    /**
     * JavaScript code for client side validation/evaluation
     *
     * @return string JavaScript code for client side validation/evaluation
     */
    public function returnFieldJS() {
        return 'return value;';
    }

    /**
     * Server-side validation/evaluation on saving the record
     *
     * @param string $value The field value to be evaluated
     * @param string $is_in The "is_in" value of the field configuration from TCA
     * @param bool $set Boolean defining if the value is written to the database or not.
     * @return string Evaluated field value
     */
    public function evaluateFieldValue($value, $is_in, &$set) {

        foreach($_POST['data']['tx_extension_domain_model_course'] as $id => $course) {
            if ( (!empty($course['start_date']) && !empty($course['start_date'])) || !empty($course['date_on_request']) ) {
                $set = true;
            } else {
                $set = false;
            }
        }
        return $value;
    }

    /**
     * Server-side validation/evaluation on opening the record
     *
     * @param array $parameters Array with key 'value' containing the field value from the database
     * @return string Evaluated field value
     */
    public function deevaluateFieldValue(array $parameters) {
        return $parameters['value'];
    }

}

      

Im looking for examples how can I do validation in JavaScript (returnFieldJS): - How do I get three fields? - How to set error classes?

And what should I check in evaluatingFieldValue ()?

+3


source to share





All Articles