简体   繁体   中英

TYPO3 Extbase contrain date in Domain Object Model

I have a model class with start date and end date. I want to make sure that the start date is always less than the end date.

I thought I might achieve this with an @validate annotation in the model class and a custom validator class like in the docs .

How can I get access to the start date value in the validate function?

<?php

namespace XXX\YYY\Domain\Model\Validator;

use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator;

class EventEndDateValidator extends AbstractValidator
{
    public function validate($endDate)
    {
       return;
        $this->addError('Validator cant do anything yet.', 42);
    }
}

Even Typo3 doesn't provide This type of functionalities, You can test in start_date and end_date in "Access" in any typo3 default element.

For this, you should use the hook and compare dates while user save record , and return false with the error message.

Let me know if you need any help related to hook

Thanks!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM