From 5df565a0b3a4f92ae95cb6017a4da44ca924dbfa Mon Sep 17 00:00:00 2001 From: Jonathan Tang Date: Thu, 24 Oct 2024 17:06:07 -0700 Subject: [PATCH] bug: if the slug contains a hyphen, then accessing the property causes a syntax error. Switched to bracket notation to correctly reference the property, as it contains a hyphen which makes dot notation invalid. --- corehq/apps/custom_data_fields/edit_entity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/corehq/apps/custom_data_fields/edit_entity.py b/corehq/apps/custom_data_fields/edit_entity.py index 67354e97852e..2b9186c49929 100644 --- a/corehq/apps/custom_data_fields/edit_entity.py +++ b/corehq/apps/custom_data_fields/edit_entity.py @@ -143,8 +143,8 @@ def make_fieldsets(self, form_fields, is_post, field_name_includes_prefix=False) data_bind_field_name = ( without_prefix(field_name, self.prefix) if field_name_includes_prefix else field_name) data_binds = [ - f"value: {self.ko_model}.{data_bind_field_name}.value", - f"disable: {self.ko_model}.{data_bind_field_name}.disable", + f"value: {self.ko_model}['{data_bind_field_name}'].value", + f"disable: {self.ko_model}['{data_bind_field_name}'].disable", ] if hasattr(field, 'choices') or without_prefix(field_name, self.prefix) == PROFILE_SLUG: data_binds.append("select2: " + json.dumps([