From: Coleman Watts Date: Fri, 27 Mar 2015 20:38:12 +0000 (-0400) Subject: CRM-16178 - Add html properties to api.getfields X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=95457d698242ed8790d069bed37dedb8b4d1c227;p=civicrm-core.git CRM-16178 - Add html properties to api.getfields --- diff --git a/CRM/Contact/Form/Edit/Individual.php b/CRM/Contact/Form/Edit/Individual.php index 32613f0be2..fb2841b047 100644 --- a/CRM/Contact/Form/Edit/Individual.php +++ b/CRM/Contact/Form/Edit/Individual.php @@ -67,25 +67,23 @@ class CRM_Contact_Form_Edit_Individual { $form->addField('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix'))); } - $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); - if (isset($nameFields['Formal Title'])) { - $form->addField('formal_title', $attributes['formal_title']); + $form->addField('formal_title'); } // first_name if (isset($nameFields['First Name'])) { - $form->addField('first_name', $attributes['first_name']); + $form->addField('first_name'); } //middle_name if (isset($nameFields['Middle Name'])) { - $form->addField('middle_name', $attributes['middle_name']); + $form->addField('middle_name'); } // last_name if (isset($nameFields['Last Name'])) { - $form->addField('last_name', $attributes['last_name']); + $form->addField('last_name'); } // suffix @@ -97,12 +95,11 @@ class CRM_Contact_Form_Edit_Individual { if (!$inlineEditMode || $inlineEditMode == 2) { // nick_name - $form->addField('nick_name', $attributes['nick_name']); + $form->addField('nick_name'); // job title // override the size for UI to look better - $attributes['job_title']['size'] = 30; - $form->addField('job_title', array('size' => '30') + $attributes['job_title']); + $form->addField('job_title', array('size' => '30')); //Current Employer Element $props = array( 'api' => array('params' => array('contact_type' => 'Organization')), @@ -125,14 +122,13 @@ class CRM_Contact_Form_Edit_Individual { $form->assign('checkSimilar', $checkSimilar); //External Identifier Element - $form->addField('external_identifier', $attributes['external_identifier'] + array('label' => 'External ID')); + $form->addField('external_identifier', array('label' => 'External ID')); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier') ); - $config = CRM_Core_Config::singleton(); CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); } } diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index d5122d752f..5bf1472853 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1227,8 +1227,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $props['data-api-field'] = $props['name']; } } - - CRM_Utils_Array::remove($props, 'entity', 'name', 'context', 'label', 'action'); + $props += CRM_Utils_Array::value('html', $fieldSpec, array()); + CRM_Utils_Array::remove($props, 'entity', 'name', 'context', 'label', 'action', 'type'); switch ($widget) { case 'Text': case 'Link': diff --git a/api/v3/utils.php b/api/v3/utils.php index b616b0ff31..7c3ec983f4 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1770,6 +1770,14 @@ function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = array()) { } $d = new $dao(); $fields = $d->fields(); + + // Set html attributes for text fields + foreach ($fields as $name => &$field) { + if (isset($field['html'])) { + $field['html'] += (array) $d::makeAttribute($field); + } + } + // replace uniqueNames by the normal names as the key if (empty($unique)) { foreach ($fields as $name => &$field) {