Are fields of Pimcore classes inheritable?

According to “Parent Class inheritance” it is possible for classes to have parent classes which are specified within the “Parent class” input field (https://pimcore.com/docs/6.x/Development_Documentation/Objects/Object_Classes/Class_Settings/Inheritance.html).

Now lets say I have created a class Animal with the fields name and description. Now I create a class Lion and a class Dolphin. Within “Parent class” I specify: Pimcore\Model\DataObject\Animal for both.

If I create a new Dolphin Data Object now with the field swimming skills (lets say Flipper). If I create Flipper then I see the field swimming skills but I do not see the fields specified for the parent class (name and description). Is there some additional action required to make this visible? Or is it simply not possible to inherit the Layout / Fields from the parent class?

Example: What I essentially want to do is to share those fields defined in a parent class across a number of child classes:

form-info

Are you sure you need a parent class? You could go with an object brick or classification store instead =)
https://pimcore.com/docs/6.x/Development_Documentation/Best_Practice/Object_Bricks_vs_Classification_Store.html

1 Like

Not completely sure about this. It seems like Object Bricks and Classification Store are great possibilities to add properties and fields to certain objects which are using all the same class definition. But what I want to do is to share a set of properties across different classes.

This is what you usually do with extending classes or by using traits. Isn’t adding object brick or classification store to any object more complicated than just having a class definition which is extendable by subclasses?

OK, then fieldcollections maybe?
https://pimcore.com/docs/6.x/Development_Documentation/Objects/Object_Classes/Data_Types/Fieldcollections.html