You could probably create a calculated custom field the lives in your task custom form (would have to live in all tasks) that automatically shows the project details of the project the task lives in. If you need this also for portfolio details, that would be a separate calculated field). Of course it’ll show blank in your task custom form anytime project/portfolio/details are not present.
If this helped you, please mark correct to help others : )