【发布时间】:2017-03-16 22:34:33
【问题描述】:
我有一个类 Publisher,我想通过属性验证对其进行验证。
但是我想覆盖默认的错误信息。
这是我的 Publisher 模型的 sn-p:
<?php
namespace Typo3\LpSurvey\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Publisher extends AbstractEntity
{
/**
* salutation
*
* @var bool
* @validate NotEmpty
*/
protected $salutation;
...
}
这是我的发布者对象的部分内容:
<div class="container publisher">
<div class="row">
<div class="col-sm-12">
<legend>Anrede <em class="star">*</em></legend>
// Error message output---------------------
<f:render partial="FormErrorsPublisher" arguments="{field: 'newSigil.survey.publisher.salutation'}" />
//------------------------------------------
<label class="label-radio">
<f:form.radio value="0" property="survey.publisher.salutation" />
Frau
</label>
<label class="label-radio">
<f:form.radio value="1" property="survey.publisher.salutation" />
Herr
</label>
</div>
</div>
...
</div>
这里是我的 FormErrorsPublisher 部分(也是一个 sn-p):
<f:form.validationResults for="{field}">
<f:if condition="{validationResults.flattenedErrors}">
<f:for each="{validationResults.flattenedErrors}" as="errors">
<ul class="error-field">
<f:for each="{errors}" as="error">
<li class="error">
{error}
</li>
</f:for>
</ul>
</f:for>
</f:if>
</f:form.validationResults>
现在,如果称呼字段为空,我会收到默认的 NotEmpty 错误消息,但我想覆盖它。
可能在带有错误代码的 locallang.xlf 中?
我尝试了这个,但没有解决方案:
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2016-10-06T09:49:41Z" product-name="lp_survey">
<header/>
<body>
...
<trans-unit id="survey.publisher.salutation.1221560910">
<source>Der angegebene Wert ist leer.</source>
</trans-unit>
</body>
</file>
</xliff>
有人有想法吗?
【问题讨论】:
标签: php validation typo3 extbase typo3-7.6.x