Use the get_search_form filter:
add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2);
function add_search_box_to_menu( $items, $args ) {
if( $args->theme_location == 'primary' )
return $items. get_search_form();
return $items;
}
add_filter( 'get_search_form', 'custom_search_form' );
function custom_search_form( $form ) {
ob_start();
// get_stylesheet_directory will get
// the main directory of the child theme
include( get_stylesheet_directory() . '/searchform.php' );
$form = ob_get_clean();
return $form;
}