Better approach to fill in the details in a form?

There are two UX patterns that I have noticed in many applications when it comes to filling in details.

  1. Creating a new entity or editing an existing one through the sliding panel Clicking on New would bring out the sliding panel

  2. Opening a new page to enter the details. This is seen mainly in places where there is a need for tabs or there are too many entries to provide. enter image description here

What are the scenarios where one would be preferable over the other? Is it recommended to use the new page pattern if there are more than a certain number of fields to be entered into the sliding panel?