-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractBaseForm.php
More file actions
executable file
·43 lines (38 loc) · 959 Bytes
/
AbstractBaseForm.php
File metadata and controls
executable file
·43 lines (38 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace BaseModule\Form;
use Zend\Form\Form;
/**
* @copyright Felix Buchheim
* @author Felix Buchheim <hanibal4nothing@gmail.com>
*/
abstract class AbstractBaseForm extends Form
{
/**
* Return a single Error per Element and not all
*
* @return array
*/
public function getSingleErrorMsgPerElement()
{
$aErrors = array();
foreach ($this->getMessages() as $sElementName => $aElement) {
$aErrors[$sElementName] = reset($aElement);
}
return $aErrors;
}
/**
* Return a string for all valid-errors
*
* @return string
*/
public function getErrorMessagesAsString()
{
$sMessage = '';
foreach($this->getMessages() as $sElementName => $aElement){
foreach($aElement as $sMessage){
$sMessage .= $sElementName . ': ' . $sMessage . PHP_EOL;
}
}
return $sMessage;
}
}