Standardize Name, Title/Label, Value

Veröffentlicht
2008-10-19 19:01
Written by
kurund - member of the CiviCRM community - view blog guidelines

Lately there has been lot of confusion using Name, Title/Label and Value. There is also a lot of inconsistency in code and database, hence we are planning to fix it in CiviCRM v2.x release.

Lets take an example of Participant Status, 'Registered'. In this case Name will be 'Registered', value will be an integer from 1..N (this depends on each install) and Label/title can be "Registered" or "I will come" etc. (or a localized version of the word/phrase).

Basic rules are:

  • Name: This is fixed value and cannot be changed by user. This is used internally in the code base to do certain actions. This will typically be in english.
  • Title/Label: This is user editable field and can be translated. This will be displayed in the system.
  • Value: Actual value that is stored in database.

There are few tables where we have adopted correct approach, like "civicrm_option_value". In this table we have separate fields name, label and value. But other table like "civicrm_membership_status" we need to add label field.Also in codebase we need to modify our pseudoconstant functions to return associated array( "value/id" => "name"). Currently it only returns associated array( "id/value" => label/title ). This is useful when you want to know ID corresponding to "Completed" contribution status. Once we have these functions we need to clean up code in ipn, contribution, pledges, event registration etc. Basically where ever we use option groups just confirm, if we are doing right thing.

Filed under