Created
January 20, 2016 01:31
-
-
Save jesseschutt/f24f931ca4520563809f to your computer and use it in GitHub Desktop.
Steps for Saving a Custom ElementType in Craft CMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create a model and populate its data (may or may not have an ID yet) | |
2. Populate the record from the model. | |
3. Validate the record and add any errors found to the model. | |
4. If the model and record are valid, save the model with the `craft()->elements->saveElement($model)` which, if successful, will place an ID on the model if there was none. | |
5. If the model saved successfully with the element service, add the model's ID to the record and save the record. | |
6. This results in the same ID being shared in the main `craft_elements` table , and your own records table. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment