function _salesforce_mapping_get_salesforce_field_options in Salesforce Suite 7.3
Helper to retreive a list of fields for a given object type.
Parameters
string $salesforce_object_type: The object type of whose fields you want to retreive.
array $form_state: Current state of the form to store and retreive results from to minimize the need for recalculation.
bool $include_select: Choice to choose a select option or not. If TRUE, the first item will be "-- Select --". If FALSE, the first item will be the first item of the retreived fields. Defaults to TRUE.
Return value
array An array of values keyed by machine name of the field with the label as the value, formatted to be appropriate as a value for #options.
1 call to _salesforce_mapping_get_salesforce_field_options()
- salesforce_mapping_form in modules/
salesforce_mapping/ includes/ salesforce_mapping.admin.inc - Return a form for a Salesforce mapping entity.
File
- modules/
salesforce_mapping/ includes/ salesforce_mapping.admin.inc, line 1102 - Configuration page for creating and modifying a mapping.
Code
function _salesforce_mapping_get_salesforce_field_options($salesforce_object_type, &$form_state, $include_select = TRUE, $type = NULL) {
$sfobject = _salesforce_mapping_get_salesforce_object($salesforce_object_type, $form_state);
$sf_fields = array();
if (isset($sfobject['fields'])) {
if ($include_select) {
$sf_fields[''] = '- ' . t('Select') . ' -';
}
foreach ($sfobject['fields'] as $sf_field) {
if ($type == NULL || $type == $sf_field['type']) {
$sf_fields[$sf_field['name']] = $sf_field['label'] . ' - (' . $sf_field['name'] . ')';
if (!$sf_field['nillable'] && $sf_field['updateable'] && $sf_field['type'] != 'boolean') {
$sf_fields[$sf_field['name']] .= '*';
}
}
}
}
natcasesort($sf_fields);
return $sf_fields;
}