Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我提交 Zend Framework 2 的表单时,我想检查每个输入是否有任何错误,如果有,请在视图中执行某些操作。
是否有任何“hasError()”(单个输入元素的)方法?对于表单,有“isValid()”方法。
谢谢
使用 getMessages() 并检查变量是否为空。
foreach ($form as $element) { $messages = $element->getMessages(); if (!empty($messages)) { // do something } }