Skip to content
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

Unable to create new templates, exception generated #10

Open
daltonrooney opened this issue Nov 15, 2024 · 2 comments
Open

Unable to create new templates, exception generated #10

daltonrooney opened this issue Nov 15, 2024 · 2 comments
Labels
bug report status: confirmed A bug report that has been reproduced by the maintainer(s), but has not yet been fixed bug report

Comments

@daltonrooney
Copy link

Bug Description

When I try to create a new template, most sections generate a 500 error on the Ajax request. Here's the response:

{
    "name": "Exception",
    "message": "Calling unknown method: spicyweb\\contenttemplates\\elements\\ContentTemplate::getSection()",
    "code": 0,
    "exception": "yii\\base\\UnknownMethodException",
    "file": "/var/www/html/craft/vendor/yiisoft/yii2/base/Component.php",
    "line": 308,
    "trace": [
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/base/Element.php",
            "line": 2537,
            "function": "__call",
            "class": "yii\\base\\Component",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/elements/conditions/entries/SectionConditionRule.php",
            "line": 63,
            "function": "__call",
            "class": "craft\\base\\Element",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/elements/conditions/ElementCondition.php",
            "line": 282,
            "function": "matchElement",
            "class": "craft\\elements\\conditions\\entries\\SectionConditionRule",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/base/FieldLayoutComponent.php",
            "line": 352,
            "function": "matchElement",
            "class": "craft\\elements\\conditions\\ElementCondition",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/models/FieldLayout.php",
            "line": 1090,
            "function": "showInForm",
            "class": "craft\\base\\FieldLayoutComponent",
            "type": "->"
        },
        {
            "function": "_elements",
            "class": "craft\\models\\FieldLayout",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/models/FieldLayout.php",
            "line": 702,
            "function": "iterator_to_array"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/base/Element.php",
            "line": 2841,
            "function": "getVisibleCustomFieldElements",
            "class": "craft\\models\\FieldLayout",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/yiisoft/yii2/base/Model.php",
            "line": 370,
            "function": "afterValidate",
            "class": "craft\\base\\Element",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/base/Element.php",
            "line": 2826,
            "function": "validate",
            "class": "yii\\base\\Model",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/services/Elements.php",
            "line": 3582,
            "function": "validate",
            "class": "craft\\base\\Element",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/services/Elements.php",
            "line": 1308,
            "function": "_saveElementInternal",
            "class": "craft\\services\\Elements",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/services/Drafts.php",
            "line": 261,
            "function": "saveElement",
            "class": "craft\\services\\Elements",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/spicyweb/craft-content-templates/src/controllers/CpController.php",
            "line": 174,
            "function": "saveElementAsDraft",
            "class": "craft\\services\\Drafts",
            "type": "->"
        },
        {
            "function": "actionCreate",
            "class": "spicyweb\\contenttemplates\\controllers\\CpController",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/yiisoft/yii2/base/InlineAction.php",
            "line": 57,
            "function": "call_user_func_array"
        },
        {
            "file": "/var/www/html/craft/vendor/yiisoft/yii2/base/Controller.php",
            "line": 178,
            "function": "runWithParams",
            "class": "yii\\base\\InlineAction",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/yiisoft/yii2/base/Module.php",
            "line": 552,
            "function": "runAction",
            "class": "yii\\base\\Controller",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/web/Application.php",
            "line": 350,
            "function": "runAction",
            "class": "yii\\base\\Module",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/web/Application.php",
            "line": 649,
            "function": "runAction",
            "class": "craft\\web\\Application",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/craftcms/cms/src/web/Application.php",
            "line": 312,
            "function": "_processActionRequest",
            "class": "craft\\web\\Application",
            "type": "->"
        },
        {
            "file": "/var/www/html/craft/vendor/yiisoft/yii2/base/Application.php",
            "line": 384,
            "function": "handleRequest",
            "class": "craft\\web\\Application",
            "type": "->"
        },
        {
            "file": "/var/www/html/public/index.php",
            "line": 26,
            "function": "run",
            "class": "yii\\base\\Application",
            "type": "->"
        }
    ]
}

For some reason, this doesn't happen when trying to create a template on all sections, but most of them.

Steps to reproduce

Try to create a new content template in any section.

Expected behaviour

No response

Content Templates version

2.0.2

Craft CMS version

5.4.10.1

@ttempleton
Copy link
Contributor

Thanks for reporting this - it seems to happen when something on the entry type's field layout has a condition rule based on the entry's section. This is kind of an awkward one, given the decoupling of sections and entry types on Craft 5. I wonder if we can ignore that condition rule (or maybe even all of them).

@ttempleton ttempleton added bug report status: confirmed A bug report that has been reproduced by the maintainer(s), but has not yet been fixed and removed bug report status: new labels Nov 18, 2024
@daltonrooney
Copy link
Author

Thanks for confirming, that's exactly right, we are using entry conditions on a few entry types so they can be re-used across multiple sections with slight variations. For our use I think we would be fine with ignoring the entry conditions when setting up the templates. But now I see the added complexity with entry types being used in multiple sections. We would want to have templates that will be relevant for a specific section only, but will show up as an option wherever that entry type is used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report status: confirmed A bug report that has been reproduced by the maintainer(s), but has not yet been fixed bug report
Projects
None yet
Development

No branches or pull requests

2 participants