function salesforce_api_fieldmap_add_form in Salesforce Suite 7.2
Same name and namespace in other branches
- 5.2 salesforce_api/salesforce_api.admin.inc \salesforce_api_fieldmap_add_form()
- 6.2 salesforce_api/salesforce_api.admin.inc \salesforce_api_fieldmap_add_form()
- 7 salesforce_api/salesforce_api.admin.inc \salesforce_api_fieldmap_add_form()
Displays the form to add a fieldmap.
1 string reference to 'salesforce_api_fieldmap_add_form'
- salesforce_api_menu in salesforce_api/
salesforce_api.module - Implements hook_menu().
File
- salesforce_api/
salesforce_api.admin.inc, line 406 - Contains the admin page callbacks for the Salesforce module, including forms for general settings and fieldmap administration.
Code
function salesforce_api_fieldmap_add_form($form, &$form_state) {
$form = array();
// Build an options array out of the Drupal objects.
$options = array();
// @todo: Find out why a bare 'node' would get loaded (no bundle)
$drupal_objects = salesforce_api_fieldmap_objects_load('drupal');
foreach ($drupal_objects as $entity_name => $bundles) {
foreach ($bundles as $bundle_name => $bundle_data) {
$options[$entity_name . ':' . $bundle_name] = $bundle_data['label'];
}
}
// If we don't have any Drupal object types, there's nothing else to do.
if (empty($options)) {
drupal_set_message(t('No Drupal objects found. Please enable a module that exposes Drupal objects to create a fieldmap, such as Salesforce Entity.'), 'error');
return array();
}
asort($options);
$form['drupal'] = array(
'#type' => 'select',
'#title' => t('Drupal object'),
'#options' => count($options) > 0 ? $options : array(
t('None available'),
),
'#disabled' => count($options) == 0,
'#required' => TRUE,
);
// Build an options array out of the Salesforce objects.
$options = array();
$sf_objects = salesforce_api_fieldmap_objects_load('salesforce');
$sf_objects = $sf_objects['salesforce'];
foreach ($sf_objects as $key => $value) {
if (!empty($value)) {
$options[$key] = $value['label'];
}
}
asort($options);
$form['salesforce'] = array(
'#type' => 'select',
'#title' => t('Salesforce object'),
'#options' => count($options) > 0 ? $options : array(
t('None available'),
),
'#disabled' => count($options) == 0,
'#required' => TRUE,
);
$form['fieldmap_name'] = array(
'#type' => 'textfield',
'#title' => t('Machine-readable name for fieldmap (Recommended)'),
'#description' => t('Enter a machine-readable name for the fieldmap,
using only letters, numbers, and underscores. If you do not select one, one will be generated.'),
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Title or short description (Optional)'),
'#description' => t('Enter a brief description of this fieldmap to distinguish it from potentially similar fieldmaps'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Map object fields'),
'#suffix' => l(t('Cancel'), SALESFORCE_PATH_FIELDMAPS),
);
return $form;
}