function civicrm_entity_form_alter in CiviCRM Entity 7.2
Implementes hook_form_alter().
File
- ./
civicrm_entity.module, line 3934
Code
function civicrm_entity_form_alter(&$form, &$form_state, $form_id) {
// For the manage display form, add a submit handler to make display suite custom civicrm "field" settings stick
if ($form_id == 'field_ui_display_overview_form') {
if (!civicrm_initialize(TRUE)) {
return;
}
$entities = _civicrm_entity_enabled_entities();
$entity_type = $form['#entity_type'];
if (array_key_exists($entity_type, $entities)) {
$submits = array();
$submits[] = '_civicrm_entity_manage_display_submit';
foreach ($form['#submit'] as $submit_callback) {
$submits[] = $submit_callback;
}
$form['#submit'] = $submits;
if ($entity_type == 'civicrm_contact' && !empty($form['fields']['civi_user'])) {
$form['fields']['civi_user']['human_name']['#markup'] = 'Drupal User (broken, do not display';
}
}
}
// for the manage fields form, if display suite forms is enabled, add a validation handler
// that enforces that the entity API required fields are set to be on the form
if ($form_id == 'field_ui_field_overview_form' && module_exists('ds_forms') && !empty($form['#ds_layout'])) {
$entities = _civicrm_entity_enabled_entities();
$entity_type = $form['#entity_type'];
if (array_key_exists($entity_type, $entities)) {
$entity_props = entity_get_property_info($entity_type);
foreach ($entity_props['properties'] as $property => $info) {
if (!empty($info['required'])) {
$form['fields'][$property]['label']['#markup'] = '<span class="form-required" title="This field is required.">* </span>' . '<span title="This field is required.">' . $form['fields'][$property]['label']['#markup'] . '</span>';
}
}
$form['#validate'][] = '_civicrm_entity_manage_display_suite_forms_validate';
}
}
}