[英]typo3 skip ObjectStorage recursive validation
I have typo3 version 8.7.17 我有typo3版本8.7.17
I have model BookedDate, with property availableDate with link to parent model. 我有模型BookedDate,具有属性availableDate和指向父模型的链接。 AvailableDate model has ObjectStorage property BookedDates.
AvailableDate模型具有ObjectStorage属性BookedDates。
My validation broken, because there is recursive validation. 我的验证失败了,因为有递归验证。 I don't need it.
我不需要 I have read a lot of similar problem but didn't find good solution or anything that works for me.
我已经读过很多类似的问题,但是没有找到好的解决方案或任何对我有用的方法。
I tried it and different variants with property paths: 我尝试了它以及带有属性路径的其他变体:
$this->arguments->getArgument($book)
->getPropertyMappingConfiguration()
->forProperty('date.bookedDates.*')
->skipProperties('bookedDate');
I need skip validation for BookedDate.date.bookedDates 我需要对BookedDate.date.bookedDates进行跳过验证
I had similar problem but no one has replied anything too. 我有类似的问题,但没有人也回答过。 TYPO3: Remove validation from ObjectStorage property in model
TYPO3:从模型的ObjectStorage属性中删除验证
So far I was able to remove validation from single relations property by custom function: 到目前为止,我已经能够通过自定义函数从单个关系属性中删除验证:
public function removePropertyValidation($argument, $property)
{
if ($this->arguments->hasArgument($argument)) {
/** @var \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator */
$conjunctionValidator = $this->arguments->getArgument($argument)->getValidator();
//get all validators for argument
foreach ($conjunctionValidator->getValidators() as $validator) {
if ($validator instanceof ConjunctionValidator) {
foreach ($validator->getValidators() as $validators) {
//get all validators for property
if ($validators instanceof GenericObjectValidator) {
foreach ($validators->getPropertyValidators($property) as $propertyValidator) {
//remove only standard validator
if ($propertyValidator instanceof ConjunctionValidator) {
foreach ($propertyValidator->getValidators() as $valid) {
$propertyValidator->removeValidator($valid);
}
}
}
}
}
}
}
}
}
Then in your initializeAction add: 然后在您的initializeAction中添加:
$this->removePropertyValidation('book', 'date');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.