Added the ability to have optgroups in form_dropdown() within the form helper.
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index c002c6f..01d0ea7 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -268,11 +268,26 @@
 		foreach ($options as $key => $val)
 		{
 			$key = (string) $key;
-			$val = (string) $val;
 
-			$sel = (in_array($key, $selected))?' selected="selected"':'';
+			if (is_array($val))
+			{
+				$form .= '<optgroup label="'.$key.'">'."\n";
 
-			$form .= '<option value="'.$key.'"'.$sel.'>'.$val."</option>\n";
+				foreach ($val as $optgroup_key => $optgroup_val)
+				{
+					$sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
+
+					$form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
+				}
+
+				$form .= '</optgroup>'."\n";
+			}
+			else
+			{
+				$sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
+
+				$form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
+			}
 		}
 
 		$form .= '</select>';