summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authornisheeth-barthwal <nisheeth.barthwal@nbaztec.co.in>2013-03-26 14:27:28 +0100
committernisheeth-barthwal <nisheeth.barthwal@nbaztec.co.in>2013-03-26 14:27:28 +0100
commit47ea5a8b99e17e9513be57d0af92f9e2637569b2 (patch)
tree8425a4e3c49c6d251eae511fa4f24d37bd526c56 /system
parent77236e055234cbbc9f6ca6be472c70077a1f5856 (diff)
Code fixes in line with suggestions
Diffstat (limited to 'system')
-rw-r--r--system/core/Input.php11
-rw-r--r--system/helpers/form_helper.php15
2 files changed, 11 insertions, 15 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index d707fe25c..1e21886ff 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -157,19 +157,20 @@ class CI_Input {
{
$value = $array[$index];
}
- elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation
+ elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation
{
- $container = $array;
+ $value = $array;
for ($i = 0; $i < $count; $i++)
{
$key = trim($matches[0][$i], '[]');
- if($key === '') // The array notation will return the value as array
+ if($key === '') // Empty notation will return the value as array
{
break;
}
- if (isset($container[$key]))
+
+ if (isset($value[$key]))
{
- $value = $container = $container[$key];
+ $value = $value[$key];
}
else
{
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 443a06a2d..e2c0cc4c5 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -642,18 +642,13 @@ if ( ! function_exists('set_value'))
*/
function set_value($field = '', $default = '', $is_textarea = FALSE)
{
- if (FALSE !== ($OBJ =& _get_validation_object()) && $OBJ->has_rule($field))
- {
- return form_prep($OBJ->set_value($field, $default), $is_textarea);
- }
-
$CI =& get_instance();
- if (NULL !== ($value = $CI->input->post($field, FALSE)))
- {
- return form_prep($value, $is_textarea);
- }
- return form_prep($default, $is_textarea);
+ $value = (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
+ ? $CI->form_validation->set_value($field, $default)
+ : $CI->input->post($field, FALSE);
+
+ return form_prep($value === NULL ? $default : $value, $is_textarea);
}
}