Form helper refactored to allow form_open() and form_fieldset() to accept arrays or strings as arguments.
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index c6aa0d2..cc08f4f 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -48,18 +48,7 @@
 

 		$form = '<form action="'.$action.'"';

 	

-		if ( ! isset($attributes['method']))

-		{

-			$form .= ' method="post"';

-		}

-	

-		if (is_array($attributes) AND count($attributes) > 0)

-		{

-			foreach ($attributes as $key => $val)

-			{

-				$form .= ' '.$key.'="'.$val.'"';

-			}

-		}

+        $form .= _attributes_to_string($attributes, TRUE);

 	

 		$form .= '>';

 

@@ -467,13 +456,7 @@
 

 		$fieldset = "<fieldset";

 

-		if (is_array($attributes) AND count($attributes) > 0)

-		{

-			foreach ($attributes as $key => $val)

-			{

-				$fieldset .= ' '.$key.'="'.$val.'"';

-			}

-		}

+        $fieldset .= _attributes_to_string($attributes, FALSE);

 	

 		$fieldset .= ">\n";

 	

@@ -610,6 +593,55 @@
 	}

 }

 

+// ------------------------------------------------------------------------

+

+/**

+ * Attributes To String

+ *

+ * Helper function used by some of the form helpers

+ *

+ * @access	private

+ * @param	mixed

+ * @param	bool

+ * @return	string

+ */	

+if ( ! function_exists('_attributes_to_string'))

+{

+	function _attributes_to_string($attributes, $formtag = FALSE)

+	{

+	   if (is_string($attributes) AND strlen($attributes) > 0)

+	   {

+		   if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)

+		   {

+			  $attributes .= ' method="post"';

+		   }

+		   

+		   return ' '.$attributes;       

+	   }

+	

+	   if (is_object($attributes) AND count($attributes) > 0)

+	   {

+		  $attributes = (array)$attributes;

+	   }

+	   

+	   if (is_array($attributes) AND count($attributes) > 0)

+	   {

+		  $atts = '';

+

+		  if ( ! isset($attributes['method']) AND $formtag === TRUE)

+		  {

+			 $atts .= ' method="post"';

+		  }

+	

+		  foreach ($attributes as $key => $val)

+		  {

+			 $atts .= ' '.$key.'="'.$val.'"';

+		  }

+

+		  return $atts;

+	   }

+	} 

+}

 

 /* End of file form_helper.php */

 /* Location: ./system/helpers/form_helper.php */
\ No newline at end of file
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index f37982c..47e517d 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -74,6 +74,11 @@
 			<li>Added support for query strings to the <a href="libraries/pagination.html">Pagination class</a>, automatically detected or explicitly declared.</li>

 		</ul>

 	</li>

+	<li>Helpers

+		<ul>

+			<li><a href="helpers/form_helper.html">Form helper</a> refactored to allow <kbd>form_open()</kbd> and <kbd>form_fieldset()</kbd> to accept arrays or strings as arguments.</li>

+		</ul>

+	</li>

 	<li>Other changes

 		<ul>

 			<li>Added ability to <a href="libraries/input.html">use xss_clean() to test images</a> for XSS, useful for upload security.</li>