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.
This commit is contained in:
Luke Towers 2020-06-17 03:05:40 -06:00
parent 68d0667bd4
commit 0cdda52eb8
1 changed files with 1 additions and 1 deletions

View File

@ -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: