-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Programmatically Created Entry Save Fails During Title renderObjectTemplate
Generation
#2705
Comments
Your fieldGroup won't have an ID unless you save it, thus your matrix property Since you can't save the matrix field you can't attach it to the elements field layout, so it won't have the expected behavior -> the exception is thrown. In general it is better to include some more |
You are correct, I was trying to strip down my example code, which was setting up a lot more than just the given entry, and must have removed those save statements as well. I have updated the comment with the correct code. |
Seems like you still don't save the field layout |
Saving an entry type also saves the associated field layout: Line 861 in 79c56d5
|
@sbossarte looking through the stack trace, what is the last step in there that refers to the above code? Which line in the code is it referring to? |
@brandonkelly This would be the line in the stack trace:
And its associated example line where it breaks. // Save it.
if (!Craft::$app->getElements()->saveElement($entry)) { |
Thanks! Fixed for the next release. |
Description
When programmatically creating a set of fields/entries/etc. Craft 3 will crash. This may be a very specific scenario, or perhaps I'm not using the API as intended any longer. This code did work in a previous RC.
Steps to reproduce
Create a field group
Create a field for that group
Create a single
Attach field to the single
Modify the entry of that single
Save the entry
Additional info
The text was updated successfully, but these errors were encountered: