-
Notifications
You must be signed in to change notification settings - Fork 66
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
Can't edit neo conditionals, getting array key 0 error #917
Comments
I'm unable to reproduce this. If possible, could you please send your composer.json, composer.lock and database backup to [email protected], along with information about a block type and nested field this is happening with, and we'll have a look. |
@ttempleton Would you like me to try to fully recreate the original bug on the non-client DB I was able to share with you? Or is this parent conditional problem clear enough on what I did send? As I said, I suspect that they are related, if not the same exact bug, but I can try to recreate it more if you like. |
Thanks for sending the email @LinneaHarts. I've been able to reproduce the array key error on a fresh Craft install, initially installed with Craft 4 and then upgraded to Craft 5. I think you're correct that the error and the missing parent field condition rules are two parts of the same bug. Unfortunately, in trying to get more parent field options to appear, so far I've only managed to (in a fairly hacky way) get options for all fields used on any of the Neo field's block types to appear (including multiple instances of the same field). While this (besides the multiple instances) is how it was on Craft 4, I'd like to get only the fields belonging to valid parent block types to appear, but might not be able to. I'll have a new release out one way or the other on Monday. |
@ttempleton Thank you! Glad to hear it I understand what you're trying to do, and it makes sense but FWIW the way it was on Craft 4 did also make a certain amount of sense since a child block could be a child of any parent, and especially before saving settings, I wasn't sure if the front end would have access that. Best of luck! |
I ended up going with all possible fields on any of the Neo field's field layouts that we have a parent block condition rule class for. That should be fixed now in Neo 5.2.0. Please let me know if any issues persist, though. |
This resolved the issues. Thank you! |
Bug Description
I just upgraded a site to Craft 5, and now conditionals aren't working when I'm editing an entry with a neo field, and also when I try to view the conditional settings for a neo field I get "Undefined array key 0"
Here is the full stack trace.
59 [web.ERROR] [yii\base\ErrorException:2] yii\base\ErrorException: Undefined array key 0 in /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php:154
Stack trace:
#0 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/ErrorHandler.php(79): yii\base\ErrorHandler->handleError()
#1 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php(154): craft\web\ErrorHandler->handleError()
#2 /mnt/www/skillsoft.com/imarcdev2/vendor/spicyweb/craft-neo/src/elements/conditions/fields/ParentFieldConditionRuleTrait.php(41): craft\fields\conditions\OptionsFieldConditionRule->field()
#3 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(471): benf\neo\elements\conditions\fields\ParentOptionsFieldConditionRule->getLabel()
#4 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(336): craft\base\conditions\BaseCondition->_ruleTypeMenu()
#5 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/View.php(1699): craft\base\conditions\BaseCondition->craft\base\conditions{closure}()
#6 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(306): craft\web\View->namespaceInputs()
#7 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/View.php(1699): craft\base\conditions\BaseCondition->craft\base\conditions{closure}()
#8 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(276): craft\web\View->namespaceInputs()
#9 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(261): craft\base\conditions\BaseCondition->getBuilderInnerHtml()
#10 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/base/FieldLayoutComponent.php(286): craft\base\conditions\BaseCondition->getBuilderHtml()
#11 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/controllers/FieldsController.php(437): craft\base\FieldLayoutComponent->getSettingsHtml()
#12 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/View.php(1699): craft\controllers\FieldsController->craft\controllers{closure}()
#13 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/controllers/FieldsController.php(437): craft\web\View->namespaceInputs()
#14 [internal function]: craft\controllers\FieldsController->actionRenderLayoutComponentSettings()
#15 /mnt/www/skillsoft.com/imarcdev2/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#16 /mnt/www/skillsoft.com/imarcdev2/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#17 /mnt/www/skillsoft.com/imarcdev2/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#18 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction()
#19 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/Application.php(650): craft\web\Application->runAction()
#20 /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/web/Application.php(311): craft\web\Application->_processActionRequest()
#21 /mnt/www/skillsoft.com/imarcdev2/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#22 /mnt/www/skillsoft.com/imarcdev2/web/index.php(28): yii\base\Application->run()
#23 {main} {"memory":127264176,"exception":"[object] (yii\base\ErrorException(code: 2): Undefined array key 0 at /mnt/www/skillsoft.com/imarcdev2/vendor/craftcms/cms/src/fields/conditions/FieldConditionRuleTrait.php:154)"}
2024-07-30 12:38:59 [web.INFO] [application] Request context:
$_GET = [
'p' => 'admin/actions/fields/render-layout-component-settings'
'site' => 'default'
'v' => '1722357537505'
]
Steps to reproduce
I think this may be related to the fact that the available parent block conditions are also wrong. The ones I see refer to conditions on the existing block, not the parent block. See screenshot here, the Icon Style is a field on the block, not the parent block.

Expected behaviour
I should be able to edit the conditional settings on child blocks with conditionals that reference parent blocks. The available parent block conditionals should refer to parent block fields.
Neo version
5.1.1
Craft CMS version
5.2.9
What is the affected Neo field's propagation method?
Only save blocks to the site they were created in
Does this issue involve templating, and if so, is eager-loading used?
This is not a templating issue
The text was updated successfully, but these errors were encountered: