Custom fields attached to a page template only show on edit screen when page is saved

If you added the Custom field only to a certain page template it won’t show on default edit screen when it stared or when you creating a new page because the new page isn’t associate with the page template yet. And when you save it shows because now the page template is added to the post.

One solution, you can use some jquery coding if you want to add the meta box when code you select the page template from dropdown.