Fix for issue #2236
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index d6e3e85..200da8a 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -642,14 +642,37 @@
 	 */
 	function set_value($field = '', $default = '', $is_textarea = FALSE)
 	{
-		if (FALSE === ($OBJ =& _get_validation_object()))
+		if (FALSE !== ($OBJ =& _get_validation_object()) && $OBJ->has_rule($field))
 		{
-			return isset($_POST[$field])
-				? form_prep($_POST[$field], $is_textarea)
-				: form_prep($default, $is_textarea);
+			return form_prep($OBJ->set_value($field, $default), $is_textarea);
 		}
 
-		return form_prep($OBJ->set_value($field, $default), $is_textarea);
+		// We couldn't find the $field in validator, so try in $_POST array
+		$index = $field;
+		$container = $_POST;
+		
+		// Test if the $field is an array name, and try to obtain the final index
+		if (preg_match_all('/\[(.*?)\]/', $field, $matches))
+		{
+			sscanf($field, '%[^[][', $index);
+			for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
+			{
+				if (isset($container[$index]) && $matches[1][$i] !== '')
+				{
+					$container = $container[$index];
+					$index = $matches[1][$i];
+				}
+				else
+				{
+					$container = array();
+					break;
+				}
+			}
+		}
+
+		return isset($container[$index]) 
+			? form_prep($container[$index], $is_textarea)
+			: form_prep($default, $is_textarea);
 	}
 }
 
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 172e799..1ed5084 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -836,6 +836,21 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * Checks if the rule is present within the validator
+	 *
+	 * Permits you to check if a rule is present within the validator
+	 *
+	 * @param	string	the field name
+	 * @return	bool
+	 */
+	public function has_rule($field)
+	{
+		return isset($this->_field_data[$field]);
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * Get the value from a form
 	 *
 	 * Permits you to repopulate a form field with the value it was submitted
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index a5f5605..2c2da6a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -244,6 +244,7 @@
 	 -  Added support for named parameters in error messages.
 	 -  :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**.
 	 -  Added rule **alpha_numeric_spaces**.
+	 -  Added method ``has_rule()`` to determine if a rule exists.
    -  Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
    -  :doc:`Caching Library <libraries/caching>` changes include:
 	 -  Added Wincache driver.
@@ -463,7 +464,7 @@
 -  Fixed a bug (#1255) - :doc:`User Agent Library <libraries/user_agent>` method ``is_referral()`` only checked if ``$_SERVER['HTTP_REFERER']`` exists.
 -  Fixed a bug (#1146) - :doc:`Download Helper <helpers/download_helper>` function ``force_download()`` incorrectly sent *Cache-Control* directives *pre-check* and *post-check* to Internet Explorer.
 -  Fixed a bug (#1811) - :doc:`URI Library <libraries/uri>` didn't properly cache segments for ``uri_to_assoc()`` and ``ruri_to_assoc()``.
--  Fixed a bug (#1506) - :doc:`Form Helpers <helpers/form_helper>` set empty *name* attributes.
+-  Fixed a bug (#1506) - :doc:`Form Helper <helpers/form_helper>` set empty *name* attributes.
 -  Fixed a bug (#59) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` ignored the DISTINCT clause.
 -  Fixed a bug (#1624) - :doc:`Form Validation Library <libraries/form_validation>` rule **matches** didn't property handle array field names.
 -  Fixed a bug (#1630) - :doc:`Form Helper <helpers/form_helper>` function ``set_value()`` didn't escape HTML entities.
@@ -488,6 +489,7 @@
 -  Fixed a bug (#2211) - :doc:`Migration Library <libraries/migration>` extensions couldn't execute ``CI_Migration::__construct()``.
 -  Fixed a bug (#2255) where ``smtp_timeout`` was not being applied to read and writes for the socket.
 -  Fixed a bug (#2239) of missing subject when using ``bcc_batch_mode``.
+-  Fixed a bug (#2236) - :doc:`Form Helper <helpers/form_helper>` incorrectly determined the value to return in method ``set_value()``.
 
 Version 2.1.3
 =============