[英]ValidateNumber localization i Flow
Actually validation is too late. 实际验证为时已晚。 What you want is map a string 12,12
to a float value 12.12
. 您想要的是将字符串12,12
映射到浮点值12.12
。 This comes before validation. 这是在验证之前。 So you need to configure the PropertyMapper. 因此,您需要配置PropertyMapper。 See comments in the \\TYPO3\\Flow\\Property\\TypeConverter\\FloatConverter
which are pretty extensive. 请参阅\\TYPO3\\Flow\\Property\\TypeConverter\\FloatConverter
中的注释,这些注释非常广泛。
Roughly this is what you need: 大概这就是您需要的:
protected function initializeCreateAction() {
$this->arguments['newBid']->getPropertyMappingConfiguration()->
forProperty('yourPropertyThatShouldBeFloat')->
setTypeConverterOption('TYPO3\Flow\Property\TypeConverter\FloatConverter', 'locale', 'de');
}
For the additional question of accepting both formats 12,12
and 12.12
as float 12.12
you probably need to write your own FloatConverter that checks for the existence of a comma and does either of the two conversions. 对于将格式12,12
和12.12
都接受为浮点数12.12
的其他问题,您可能需要编写自己的FloatConverter来检查是否存在逗号并进行两次转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.