We'll cover how to create a field layout in Craft CMS with a content migration.
The next thing we want to create for our contact form section is to create a layout field so we can create a publish form in the contact submissions section of the Craft project.
We’ll first create a migration for this new field layout:
craft migrate/create add_field_layout
The first thing we need to do is get the fields that we already created because we are going to add them to the field layout.
After that, we’ll fetch the default entry type that was created when we created the new Contact Form section in a previous migration.
From the entry type, we can retrieve the field layout using the getFieldLayout() method.
As part of the new layout, we’ll create a new tab and give it the name “Content Submissions” using a new instance of FieldLayoutTab.
With the tab created, we use the setFields method to set the fields to the tab and then set the tab using setTabs() on the field layout.
Finally, we save the new layout using saveLayout via Craft::$app->fields->saveLayout($fieldLayout).

I am the creator of CraftQuest, a web developer, and former software team manager. I spend most of my time improving CraftQuest with code and courses. When I'm not in front of the computer, I spend my time with my family, and running on the roads and trails of Austin, TX.