WordPress Metabox不会保存

I was trying to make my metabox work but for some reason whenever I put some text and try to save the data inside the textarea it wont save.

add_action("admin_init", "custom_product_metabox");

function custom_product_metabox(){
  add_meta_box("custom_product_metabox_01", "Product Description", "custom_product_metabox_field", "portfolio_page", "normal", "low");
}

function custom_product_metabox_field(){
    global $page;

    $data = get_post_custom($page->ID);
    $val = isset($data['custom_product_input']) ? esc_attr($data['custom_product_input'][0]) : 'no value';
    echo '<textarea rows="5" cols="220" name="custom_product_input" id="custom_product_input" value="'.$val.'"></textarea>';
}

add_action("save_post", "save_detail");

function save_detail(){
    global $page;

    if(define('DOING_AUTOSAVE') && DOING_AUTOSAVE){
        return $page->ID;
    }

    update_post_meta($page->ID, "custom_product_input", $_POST["custom_product_input"]);
}

This is actually a code for a portfolio page where I embedded inside the functions.php. Any idea how can I make it work and save the data?

Thanks!

Your save method looks wrong. Try something like

function custom_product_metabox_field($post){
    //global $page; remove this line also

    $data = get_post_custom($post->ID);
    $val = !empty(get_post_meta( $post->ID, 'custom_product_input', true )) ? 
   get_post_meta( $post->ID, 'custom_product_input', true ) : 'no value';
    echo '<textarea rows="5" cols="220" name="custom_product_input" id="custom_product_input" value="'.$val.'"></textarea>';
} 

add_action("save_post", "save_detail", 10, 3 );

function save_detail($post_id, $post, $update){
   //global $page;// remove this line

   if(define('DOING_AUTOSAVE') && DOING_AUTOSAVE){
       return $post_id;
   }

   update_post_meta($post_id, "custom_product_input", $_POST["custom_product_input"]);
}