This movie is based on true story. There is a prophetic hadith narrating the story of the boy and king. For details see hadith no-30 of “Riadus Saliheen”.