--- C:\Users\Ramesh\AppData\Local\Temp\system.inc-revBASE.svn000.tmp.inc	2010-07-08 12:40:55.000000000 +-0100
+++ Q:\nbc\kola_rnair\src\sites\all\modules\patterns\components\system.inc	2010-07-08 12:26:03.000000000 +-0100
@@ -132,12 +132,22 @@
         	if ($data['value']) {
         		$data['theme_default'] = $data['value'];
             $data['status'][$data['value']] = $data['value'];
         	}
         break;
         case 'form':
+          // Some forms may be submitting fields with array-style names, e.g. formats[1]['editor']
+          // But XML doesn't allow for tag names starting with digits.
+          // So we implement a hack which allows the use of tags in the following format:
+          //
+          // <__xxx__>  where xxx can be a single digit, letter or a normal tag name
+          // 
+          // In this code block we will trim off the '__' bits now that the XML has been converted 
+          // to an array.
+          _system_patterns_form_cleanup_tagnames($data);
+        	
           // attempt to load required include file
           $menu = menu_router_build(TRUE);
           foreach ($menu as $item) {
             if ($item['page arguments'][0] == $data['form_id']) {
               $data['include'] = $item['include file'];
               break;
@@ -347,6 +357,28 @@
       if ($id == 'system_modules') {
         menu_rebuild();
       }
     break;
   }
 }
+
+/**
+ * We want to allow for tagnames containing just a digit when using the 'form' tag since some 
+ * forms requires the use of field names containing digits as array keys.
+ *  
+ * But because we can't use such tags (e.g. <1>) in XML we workaround the problem by allowing the 
+ * tag to be written as <__1__>. This method will strip the underscores from such tags whilst still 
+ * allowing for other tag names which use the underscore as normal.
+ *   
+ */
+function _system_patterns_form_cleanup_tagnames(&$data = array()) {
+	$keys = array_keys($data);
+	foreach ($keys as $key) {
+		if (is_array($data[$key]) && !empty($data[$key]))
+		  _system_patterns_form_cleanup_tagnames($data[$key]);
+    $newkey = preg_replace('/__(.+)__/iA','$1',$key);
+		if ($newkey != $key) {
+      $data[$newkey] = $data[$key];
+			unset($data[$key]);
+		}
+	}
+}
