File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
app/code/core/Mage/Contacts/controllers Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -75,18 +75,21 @@ public function postAction()
75
75
$ postObject = new Varien_Object ();
76
76
$ postObject ->setData ($ post );
77
77
78
- // check data
79
- $ error = false ;
80
78
$ validator = Validation::createValidator ();
81
- if ($ validator ->validate (trim ($ post ['name ' ]), new Assert \Length (['min ' => 1 , 'max ' => 255 ]))->count () > 0 ) {
82
- $ error = true ;
83
- } elseif ($ validator ->validate (trim ($ post ['comment ' ]), new Assert \Length (['min ' => 1 , 'max ' => 2048 ]))->count () > 0 ) {
84
- $ error = true ;
85
- } elseif ($ validator ->validate (trim ($ post ['email ' ]), [new Assert \NotBlank (), new Assert \Email ()])->count () > 0 ) {
86
- $ error = true ;
79
+ $ violations = [];
80
+ $ errors = new ArrayObject ();
81
+
82
+ $ violations [] = $ validator ->validate (trim ($ post ['name ' ]), new Assert \Length (['min ' => 1 , 'max ' => 255 ]));
83
+ $ violations [] = $ validator ->validate (trim ($ post ['comment ' ]), new Assert \Length (['min ' => 1 , 'max ' => 2048 ]));
84
+ $ violations [] = $ validator ->validate (trim ($ post ['email ' ]), new Assert \Length (['min ' => 1 , 'max ' => 2048 ]));
85
+
86
+ foreach ($ violations as $ violation ) {
87
+ foreach ($ violation as $ error ) {
88
+ $ errors ->append ($ error ->getMessage ());
89
+ }
87
90
}
88
91
89
- if ($ error ) {
92
+ if (count ( $ errors ) !== 0 ) {
90
93
Mage::throwException ($ this ->__ ('Unable to submit your request. Please, try again later ' ));
91
94
}
92
95
You can’t perform that action at this time.
0 commit comments