dynamically add a custom field or metabox to custom post type [duplicate]

To add a metabox to a post type car use the proper hook:

add_action( 'add_meta_boxes_car', 'register_car_metabox' );

function register_car_metabox()
{

    add_meta_box(
        'car-data',
        'Car data',
        'car_metabox_callback',
        NULL,
        'normal',
        'default'
    );
}

The content will be created in your callback:

function car_metabox_callback()
{
    # get post meta and print input fields
}