Hi,
I got an input for mobile (entry:0012345678) which I want to format to 00 12 34 56 78, so I've tried to use callback_before_insert like this :
$crud->callback_before_insert(array($this,'format_phone'));
and
my function :
function format_phone($post_array) { $post_array = preg_replace('/[^0-9]+/', '', $post_array); $post_array = substr($post_array, -9); $pattern = '0\1 \2 \3 \4 \5'; $post_array = preg_replace('/(\d{1})(\d{2})(\d{2})(\d{2})(\d{2})/', $pattern, $post_array); return $post_array; }
But when I add a contact the number still appear in 0012345678 format, did I missed something ? (The function works fine, I've tested it)
Thx in advance