From 0cdda52eb8d6f0994ac4aa114f37742faa426a55 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 17 Jun 2020 03:05:40 -0600 Subject: [PATCH] Fix bug where a field with `@context` in the name would completely break forms if it also depended on other fields. The bug occurred because if specific fields aren't detected in onRefresh(), the entire Form widget HTML will be returned as the result instead of specific fields. This created a problem because the october.form.js JS is not setup to gracefully handle having the entire root form DOM node completely replaced in the middle of a request being completed. Specifically, this would cause problems when trying to detect empty tabs, and then the problems would cascade from there as there would be an instance of october.form.js attached to the page with broken references to no-longer existing DOM nodes. This fix solves the immediate issue of `field@context` using the `dependsOn` feature breaking by ensuring that the actual final field name for a given field is used instead of the name used in the configuration of the field. Future work should probably be done to better support an entire form being re-rendered if no fields are detected in onRefresh however. --- modules/backend/widgets/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 241d8d4ba..5b79a6c75 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -737,7 +737,7 @@ class Form extends WidgetBase $this->model->setValidationAttributeName($attrName, $fieldObj->label); } - $this->allFields[$name] = $fieldObj; + $this->allFields[$fieldObj->fieldName] = $fieldObj; switch (strtolower($addToArea)) { case FormTabs::SECTION_PRIMARY: