Solved: Field Sections from Multiple Base Templates Not Merging

The Problem

It’s a common situation:

  1. Your templates are set up for multiple inheritance
  2. In more than one of these templates, you want to use the same field section and have the fields appear side-by-side
  3. You want to control the order the fields appear in the content editor

How do you go about setting this up?

  1. Create your templates, fields, and inheritance structure
  2. Ensure that the field sections are named exactly the same if you want their contained fields to be merged
  3. Ensure that the Sort Order field for all field sections that share a name are set identically

What’s the problem?

Sometimes, this doesn’t work. The fields seem to order themselves however they see fit. Often times this means all the fields from one template are mashed together at the top of the section, ignoring the meticulous sort order values you’ve set.

In the below example, I have three templates: Car Base, Sedan, and Truck. Sedan and Truck both inherit from Car Base.

template_hierarchy

All three templates’ Car Properties field sections have their Sort Order field values set to 100. The fields have the following sort orders:

  • Car Base.Doors: 100
  • Car Base.Engine Size: 200
  • Sedan.Trunk Space: 150
  • Truck.Towing Capacity: 150

car_beforetruck_before

For some reason, though, Trunk Space and Towing Capacity are showing up at the top of the Car Properties section when editing a sedan and truck, respectively. Based on the sort orders I listed above, this shouldn’t be happening…right?

How do I solve it?

Set the Sort Order values on each field section. Even if you want them all to be ‘100’, it is not enough to rely on the Sort Order field’s standard value. You must change it to something else, save it, change it back to 100, and save it again.

That means that this:

sort_order_before

Becomes this:

sort_order_after

Which makes for happy developers and even happier editors.

car_after

One thought on “Solved: Field Sections from Multiple Base Templates Not Merging

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: