Working with Entity Types
In our example, we are trying to create a site where we will have vehicle listings. For that purpose we needed an entity type to store our vehicle entities.
To create an entity type with ECK we need to go to /admin/structure/entity-type
Then we will have the option to "add entity type" to Drupal.
After clicking on "add entity type", we need to give our Entity type a name. For our example we will call our entity type "Vehicle". There is also an optional field to give a bundle name. When we were defining our data model we realized that we needed 2 bundles or subtypes: car and truck. By default, ECK creates one bundle with every entity type, and this optional field gives us a chance to give that bundle a name instead of the default (By default the bundle will be name the same than the entity type). Since we know that we need a car and truck bundles, lets go ahead and type "Car" in the optional Bundle field.
In this screen we also have an option to add commonly used properties to our entity type. This default properties are managed by ECK, so the created date gets recorded automatically when an entity of this type is created, the author property gets set to the active user in the system during the creation of an entity etc.
Default properties can be activated on this screen or at a later time from the screen where extra properties can be added.
For right now lets not use any of our default properties and click save.
After clicking save we will see a message letting us know that our entity type has been created. If we go back to /admin/structure/entity-type we will see that we now have our Vehicle entity type, so we can continue to add the necessary properties to store information in our vehicle entities.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion