所以我知道如果您根据模型的验证器对其进行验证,CakePHP 会自动将错误消息加载到视图中。我正在尝试设置日期保管箱验证,并且我想控制错误消息的显示位置。
在提交验证表单之前:
<div class="input text required">
<label for="UserEmail">Email</label>
<input name="data[User][email]" maxlength="50" type="text" id="UserEmail">
</div>
验证后,此处显示错误:
<div class="input text required error">
<label for="UserEmail">Email</label>
<input name="data[User][email]" maxlength="50" type="text" value="" id="UserEmail" class="form-error">
<div class="error-message">An email is required</div>
</div>
是否可以控制它显示在哪里?
<div class="input text required error">
<div class="error-message">An email is required</div>
<label for="UserEmail">Email</label>
<input name="data[User][email]" maxlength="50" type="text" value="" id="UserEmail" class="form-error">
</div>
或者在这里:
<div class="error-message">An email is required</div>
<div class="input text required error">
<label for="UserEmail">Email</label>
<input name="data[User][email]" maxlength="50" type="text" value="" id="UserEmail" class="form-error">
</div>