spicywebau / craft-neo

A Matrix-like field type for Craft CMS that uses existing fields
Other
403 stars 63 forks source link

[5.x] Error after changing field handle: Field is not included in the available field layouts #884

Closed bryce-pod1 closed 2 months ago

bryce-pod1 commented 2 months ago

Bug Description

After changing a fields handle via "Settings" in a blocks Field Layout, an error pops up when accessing it's Settings again:

Field [fieldUid] is not included in the available field layouts.

If you then save the Neo field and refresh, the CP shows the same error and is unusable. To get the CP working again you have to change the handle to null in it's config yaml within "config/project/neo/blockTypes"

This wasn't happening previously (beta 7, I think I updated through 8 and 9 all at the same time) Doesn't happen when changing field handles on Entry Types

Steps to reproduce

  1. Create Neo field (add block type and layout tab of course)
  2. Create and add Plain Text field to Field Layout (also tested other field types)
  3. Open fields Settings (not Edit field)
  4. Type something in Handle input and Apply
  5. Open fields Settings again (error pops up in bottom left of screen)
  6. Save Neo field
  7. Refresh (page errors out)

Expected behaviour

No response

Neo version

5.0.0-beta.9

Craft CMS version

5.1.0

What is the affected Neo field's propagation method?

No response

Does this issue involve templating, and if so, is eager-loading used?

This is not a templating issue

ttempleton commented 2 months ago

Changing the field handle in settings is working correctly for me.

Just to confirm - the field UID in the error matches that of the field having its handle overridden?

If you updated Craft at the same time, do you still get the error if you downgrade Craft to the previously-used version and keep Neo at 5.0.0-beta.9?

ttempleton commented 2 months ago

Could you please also post the stack trace if possible?

bryce-pod1 commented 2 months ago

Yup the field UID matches, and setting the handle back to null in the blockType config yaml stops the error.

Downgrading to Craft 5.0.6 fixes the error too - that's prev version right? Edit: After upgrading again I can't get the whole CP to error when opening the Neo field page like yesterday. The Popup error still happends when opening the inner fields settings which stops you from being able to change remove the custom handle.

Here's the stack trace.

[yii\base\InvalidConfigException] yii\base\InvalidConfigException: Field 7bbbab1d-2aa7-4708-8723-528bd86284d9 is not included in the available field layouts. in /var/www/html/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php:119
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php(193): craft\fields\conditions\TextFieldConditionRule->fieldInstances()
#1 /var/www/html/vendor/craftcms/cms/src/elements/conditions/ElementCondition.php(146): craft\fields\conditions\TextFieldConditionRule->getExclusiveQueryParams()
#2 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(129): craft\elements\conditions\ElementCondition->isConditionRuleSelectable(Object(benf\neo\elements\conditions\fields\ParentTextFieldConditionRule))
#3 [internal function]: craft\base\conditions\BaseCondition->craft\base\conditions\{closure}(Object(benf\neo\elements\conditions\fields\ParentTextFieldConditionRule), '{"class":"benf\\...')
#4 /var/www/html/vendor/illuminate/collections/Arr.php(911): array_filter(Array, Object(Closure), 1)
#5 /var/www/html/vendor/illuminate/collections/Collection.php(387): Illuminate\Support\Arr::where(Array, Object(Closure))
#6 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(129): Illuminate\Support\Collection->filter(Object(Closure))
#7 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(269): craft\base\conditions\BaseCondition->getSelectableConditionRules()
#8 /var/www/html/vendor/craftcms/cms/src/web/View.php(1669): craft\base\conditions\BaseCondition->craft\base\conditions\{closure}()
#9 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(267): craft\web\View->namespaceInputs(Object(Closure), 'elementConditio...')
#10 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(252): craft\base\conditions\BaseCondition->getBuilderInnerHtml()
#11 /var/www/html/vendor/craftcms/cms/src/base/FieldLayoutComponent.php(286): craft\base\conditions\BaseCondition->getBuilderHtml()
#12 /var/www/html/vendor/craftcms/cms/src/controllers/FieldsController.php(437): craft\base\FieldLayoutComponent->getSettingsHtml()
#13 /var/www/html/vendor/craftcms/cms/src/web/View.php(1669): craft\controllers\FieldsController->craft\controllers\{closure}()
#14 /var/www/html/vendor/craftcms/cms/src/controllers/FieldsController.php(437): craft\web\View->namespaceInputs(Object(Closure), 'oihsvwqdcu')
#15 [internal function]: craft\controllers\FieldsController->actionRenderLayoutComponentSettings()
#16 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#18 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('render-layout-c...', Array)
#19 /var/www/html/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction('fields/render-l...', Array)
#20 /var/www/html/vendor/craftcms/cms/src/web/Application.php(650): craft\web\Application->runAction('fields/render-l...', Array)
#21 /var/www/html/vendor/craftcms/cms/src/web/Application.php(311): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#22 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#23 /var/www/html/web/index.php(12): yii\base\Application->run()
#24 {main} {"memory":2487944,"exception":"[object] (yii\\base\\InvalidConfigException(code: 0): Field 7bbbab1d-2aa7-4708-8723-528bd86284d9 is not included in the available field layouts. at /var/www/html/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php:119)"} 
bryce-pod1 commented 2 months ago

I got it to error the whole CP on Craft 5.0.6 with Neo 5.0.0-beta.8 on my staging server, but not on local DDEV, so it seems that might be an environment issue. But it's not happening there with the latest versions of Craft and Neo, so I was wrong on that in my original comment it seems.

With the originally mentioned versions of Craft and Neo on both staging and DDEV, the error does still pop up when trying to edit nested field settings and stops the settings panel from opening.

Here's the stack trace from the whole CP error on the staging server - not sure if it helps, as that full page error is fixed, but it is the same error message.

yii\base\InvalidConfigException: Field 7bbbab1d-2aa7-4708-8723-528bd86284d9 is not included in the available field layouts. in /var/www/html/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php:119
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php(193): craft\fields\conditions\TextFieldConditionRule->fieldInstances()
#1 /var/www/html/vendor/craftcms/cms/src/elements/conditions/ElementCondition.php(116): craft\fields\conditions\TextFieldConditionRule->getExclusiveQueryParams()
#2 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(129): craft\elements\conditions\ElementCondition->isConditionRuleSelectable()
#3 [internal function]: craft\base\conditions\BaseCondition->craft\base\conditions\{closure}()
#4 /var/www/html/vendor/illuminate/collections/Arr.php(911): array_filter()
#5 /var/www/html/vendor/illuminate/collections/Collection.php(387): Illuminate\Support\Arr::where()
#6 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(129): Illuminate\Support\Collection->filter()
#7 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(269): craft\base\conditions\BaseCondition->getSelectableConditionRules()
#8 /var/www/html/vendor/craftcms/cms/src/web/View.php(1669): craft\base\conditions\BaseCondition->craft\base\conditions\{closure}()
#9 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(267): craft\web\View->namespaceInputs()
#10 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(252): craft\base\conditions\BaseCondition->getBuilderInnerHtml()
#11 /var/www/html/vendor/craftcms/cms/src/base/FieldLayoutComponent.php(275): craft\base\conditions\BaseCondition->getBuilderHtml()
#12 /var/www/html/vendor/craftcms/cms/src/helpers/Cp.php(2336): craft\base\FieldLayoutComponent->getSettingsHtml()
#13 /var/www/html/vendor/craftcms/cms/src/helpers/Cp.php(2188): craft\helpers\Cp::_fldTabSettingsData()
#14 /var/www/html/vendor/craftcms/cms/src/web/twig/variables/Cp.php(1083): craft\helpers\Cp::fieldLayoutDesignerHtml()
#15 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1635): craft\web\twig\variables\Cp->fieldLayoutDesigner()
#16 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(141): twig_get_attribute()
#17 /var/www/html/storage/runtime/compiled_templates/ab/ab3362015b550185799080ba16d12bb1.php(40): craft\helpers\Template::attribute()
#18 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_09201743cb9dde141cbebbe61375106e->doDisplay()
#19 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
#20 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
#21 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()
#22 /var/www/html/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render()
#23 /var/www/html/vendor/craftcms/cms/src/web/View.php(482): Twig\Environment->render()
#24 /var/www/html/vendor/craftcms/cms/src/helpers/Cp.php(113): craft\web\View->renderTemplate()
#25 /var/www/html/vendor/craftcms/cms/src/helpers/Cp.php(1179): craft\helpers\Cp::renderTemplate()
#26 /var/www/html/vendor/craftcms/cms/src/web/twig/variables/Cp.php(1070): craft\helpers\Cp::fieldHtml()
#27 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1635): craft\web\twig\variables\Cp->field()
#28 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(141): twig_get_attribute()
#29 /var/www/html/storage/runtime/compiled_templates/2a/2a6655036bef19b786b36c61e02ba866.php(1257): craft\helpers\Template::attribute()
#30 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1224): __TwigTemplate_6ce9521e93e27048a8058d8fb713023f->macro_field()
#31 /var/www/html/storage/runtime/compiled_templates/2a/2a6655036bef19b786b36c61e02ba866.php(2285): twig_call_macro()
#32 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1224): __TwigTemplate_6ce9521e93e27048a8058d8fb713023f->macro_fieldLayoutDesignerField()
#33 /var/www/html/storage/runtime/compiled_templates/82/823853c2dd58be5315f4bc76d7e2b5d7.php(43): twig_call_macro()
#34 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_fd99889f2e724464cf8d99b6c9c68fc3->doDisplay()
#35 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
#36 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
#37 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()
#38 /var/www/html/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render()
#39 /var/www/html/vendor/craftcms/cms/src/web/View.php(482): Twig\Environment->render()
#40 /var/www/html/vendor/spicyweb/craft-neo/src/services/BlockTypes.php(809): craft\web\View->renderTemplate()
#41 /var/www/html/vendor/spicyweb/craft-neo/src/assets/SettingsAsset.php(106): benf\neo\services\BlockTypes->renderFieldLayoutDesigner()
#42 /var/www/html/vendor/spicyweb/craft-neo/src/Field.php(565): benf\neo\assets\SettingsAsset::createSettingsJs()
#43 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1635): benf\neo\Field->getSettingsHtml()
#44 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(141): twig_get_attribute()
#45 /var/www/html/storage/runtime/compiled_templates/58/58fc2ff57b03301aa160fd2b0b0d6de4.php(46): craft\helpers\Template::attribute()
#46 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_067a6297e75d04eb66fd4265e50abeae->doDisplay()
#47 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
#48 /var/www/html/storage/runtime/compiled_templates/17/178e234d9e8c2058e20bf0eb83dc7c79.php(156): Twig\Template->display()
#49 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_29198d7b0fb6afd70eb31bcd14a00dc2->doDisplay()
#50 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
#51 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
#52 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()
#53 /var/www/html/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render()
#54 /var/www/html/vendor/craftcms/cms/src/web/View.php(482): Twig\Environment->render()
#55 /var/www/html/vendor/craftcms/cms/src/web/CpScreenResponseBehavior.php(622): craft\web\View->renderTemplate()
#56 [internal function]: craft\web\CpScreenResponseBehavior->craft\web\{closure}()
#57 /var/www/html/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(133): call_user_func()
#58 /var/www/html/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(50): craft\web\CpScreenResponseFormatter->_formatTemplate()
#59 /var/www/html/vendor/yiisoft/yii2/web/Response.php(1100): craft\web\CpScreenResponseFormatter->format()
#60 /var/www/html/vendor/craftcms/cms/src/web/Response.php(337): yii\web\Response->prepare()
#61 /var/www/html/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#62 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#63 /var/www/html/web/index.php(12): yii\base\Application->run()
#64 {main}
ttempleton commented 2 months ago

Thanks for that information - I was able to reproduce it, and it's fixed now in 5.0.0-beta.10.