We're updating the issue view to help you get more done. 

Empty attributes get saved due to locale_id key in request

Description

Hi,

I've been having trouble with a single-valued attribute (on entities):

  • when the entity is first created the field is left empty

  • when it is later edited the system tries to insert a new attribute which fails due to the single value limit (the attribute already exists)

  • when the field is filled in upon creation there are no such troubles

I've been looking into this and I've found that something strange happens in BundlableLableBaseModelWithAttributes->saveBundlesForScreen (line 2111)

It runs through all the keys in $_REQUEST and whenever the regex succeeds an attribute is added, however we have two keys for the 'new' attribute:

  • ca_attribute_civicrm_idEntityEditorForm_attribute_91_91_new_0

  • ca_attribute_civicrm_idEntityEditorForm_attribute_91_locale_id_new_0

Even though the first one is left empty, a new attribute is created due to the second key (containing the locale_id matching the regex)

This attribute can no longer be changed because of the limitation that it should be singular (BaseModelWithAttributes->getAttributeCountByElement returns 1)

If put an if (strpos($vs_key, 'locale_id') === false) around the block and this fixes it for us, but i wonder whether i'm on the right track here. Could you please have a look?

Kind Regards,
Thimo

Environment

LAMP

Assignee

User known

Reporter

Thimo Thoeye

Labels

None

Components

Affects versions

Priority

Minor
Configure