Details
-
Type: Sub-task
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.4.0
-
Fix Version/s: None
-
Component/s: CiviCRM Profile, CiviHR
-
Labels:None
Description
Several forms used in CiviHR are generated as profile-forms with custom-data. These forms have HTML elements (<INPUT>, <SELECT>, etc) with the attribute "name=custom_X" (where X varies from system to system). This makes it hard to work with programmatically – for example, it is difficult to write JavaScript UI's and automated web-tests. To improve this, we should add more markup to the HTML elements, e.g.
<INPUT name="custom_X" data-crm-custom="TheCustomGroup:TheCustomField" />
<SELECT name="custom_X" data-crm-custom="TheCustomGroup:TheCustomField">...</SELECT>
where "TheCustomGroup" and "TheCustomField" correspond to the values in civicrm_custom_group.name and civicrm_custom_field.name (respectively). This will enable one to write selectors like:
cj('[data-crm-custom="TheCustomGroup:TheCustomField"]').val('new value')
The function CRM_Core_BAO_CustomField::addQuickFormElement() is responsible for reading a $field (DAO) and producing its HTML form-elements. This is probably the place to patch. (Aside: CRM_Core_BAO_UFGroup::buildProfile is also important in generating profile forms, but I don't think it has any direct impact on the markup used for custom-fields.)