/ Published in: PHP

CodeIgniter Helper function to repopulate form values when a muli-dimensional post array key is used.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Repopulate form values when a muli-dimensional post array key is used. * * @param string $field * @param string $index * @param string $default * @return string */ function set_multi_value($field, $index=null, $default=null) { $CI = & get_instance(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { return $CI->security->xss_clean($_POST[$matches[1]][$matches[2]]); return $CI->security->xss_clean($_POST[$field][$index]); return $CI->security->xss_clean($_POST[$field]); } else { return $CI->security->xss_clean($default); } return $CI->security->xss_clean($default); } else { return ''; } } }
Comments
