summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authornisheeth-barthwal <nisheeth.barthwal@nbaztec.co.in>2013-03-21 11:18:10 +0100
committernisheeth-barthwal <nisheeth.barthwal@nbaztec.co.in>2013-03-21 11:18:10 +0100
commita7447d205296eeead94617f4b66707e336547b51 (patch)
treeef73cd6e834cc732bf706aad2b8a6a60988983f5 /system/helpers
parent76f42d9dcd42bf90c407f151d04ef207c8deebdf (diff)
Added array notation for keys in Input library
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/form_helper.php44
1 files changed, 39 insertions, 5 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 692909c79..d2c22b05c 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -642,14 +642,17 @@ if ( ! function_exists('set_value'))
*/
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 form_prep($OBJ->set_value($field, $default), $is_textarea);
+ }
+
+ if (FALSE !== ($OBJ =& _get_input_object()) && ($value = $OBJ->post($field, FALSE, TRUE)))
{
- return isset($_POST[$field])
- ? form_prep($_POST[$field], $is_textarea)
- : form_prep($default, $is_textarea);
+ return form_prep($value, $is_textarea);
}
- return form_prep($OBJ->set_value($field, $default), $is_textarea);
+ return form_prep($default, $is_textarea);
}
}
@@ -1004,5 +1007,36 @@ if ( ! function_exists('_get_validation_object'))
}
}
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('_get_input_object'))
+{
+ /**
+ * Input Object
+ *
+ * Fetches the input object
+ *
+ * @return mixed
+ */
+ function &_get_input_object()
+ {
+ $CI =& get_instance();
+
+ // We set this as a variable since we're returning by reference.
+ $return = FALSE;
+
+ if ( ! isset($CI->input) OR ! is_object($CI->input))
+ {
+ return $return;
+ }
+ else
+ {
+ $return = $CI->input;
+ }
+
+ return $return;
+ }
+}
+
/* End of file form_helper.php */
/* Location: ./system/helpers/form_helper.php */ \ No newline at end of file