本文介绍了消除SilverStripe 3表单上的文本泡泡错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,我得到了两种不同类型的错误消息,如同引用的屏幕截图所示。如何在电子邮件字段中删除文本气泡样式错误消息,并让它们看起来像名称字段上的错误框?



屏幕截图:



在SilverStripe 3.0 / 1中,它启用了使用HTML5所需的属性,这些属性由Web浏览器提取并进行自己的验证如果您想停止浏览器行为,请从SilverStripe提供的标记中移除必需的属性。

  TextField :: create('MyTextField') - > setAttribute('required',false)

这仍然会使PHP验证所需的表单字段失效,但会禁用浏览器弹出窗口。


For some reason I'm getting two different kinds of error messages on the same SS 3 form as shown in the referenced screenshot. How do I get rid of the text bubble style error message on the email field and have them all look like the error box on the name field?

Screenshot: http://d.pr/i/ThmL

Bob

解决方案

In SilverStripe 3.0/1 it enabled the use of the HTML5 required attributes which web browsers pick up and do their own validation for (which you've seen).

If you want to stop the browser behaviour remove the required attribute from the markup SilverStripe provides

TextField::create('MyTextField')->setAttribute('required', false)

This will still make the form field required in the PHP validation but disable the browser popup.

这篇关于消除SilverStripe 3表单上的文本泡泡错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 22:10