Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DracoBlue/2767576 to your computer and use it in GitHub Desktop.
Save DracoBlue/2767576 to your computer and use it in GitHub Desktop.
Index: libs/agavi/filter/AgaviFormPopulationFilter.class.php
===================================================================
--- libs/agavi/filter/AgaviFormPopulationFilter.class.php (revision 351)
+++ libs/agavi/filter/AgaviFormPopulationFilter.class.php (revision 355)
@@ -580,7 +580,22 @@
// now output the remaining incidents
// might include errors for cookies, headers and whatnot, but that is okay
- if($this->insertErrorMessages($form, $errorMessageRules, $allIncidents)) {
+ if($this->insertErrorMessages($form, $errorMessageRules, $allIncidents) && count($allIncidents)) {
+ // go over all the elements in the error class map
+ foreach($cfg['error_class_map'] as $xpathExpression => $errorClassName) {
+ // evaluate each xpath expression
+ $errorClassResults = $this->xpath->query(AgaviToolkit::expandVariables($xpathExpression, array('htmlnsPrefix' => $this->xmlnsPrefix)), $form);
+ if($errorClassResults && $errorClassResults->length) {
+ // we have results. the xpath expressions are used to locale the actual elements we set the error class on - doesn't necessarily have to be the erroneous element or the label!
+ foreach($errorClassResults as $errorClassDestinationElement) {
+ $errorClassDestinationElement->setAttribute('class', preg_replace('/\s*$/', ' ' . $errorClassName, $errorClassDestinationElement->getAttribute('class')));
+ }
+
+ // and break the foreach, our expression matched after all - no need to look further
+ break;
+ }
+ }
+
$allIncidents = array();
}
}
@@ -1051,4 +1066,4 @@
}
}
-?>
\ No newline at end of file
+?>
@graste
Copy link

graste commented Jun 14, 2012

Name des Patches: agavi_fix_error_map_class_with_no_field_specific_errors.patch

@DracoBlue
Copy link
Author

Added proper name for the .patch file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment