function salesforce_mapping_form_field_callback in Salesforce Suite 7.3
Ajax callback for deleting a field mapping row.
1 string reference to 'salesforce_mapping_form_field_callback'
- 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 421 - Configuration page for creating and modifying a mapping.
Code
function salesforce_mapping_form_field_callback($form, $form_state) {
$errors = array(
'#theme' => 'status_messages',
);
$ajax_warn = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'messages',
'warning',
),
),
'message' => array(
'#type' => 'markup',
'#markup' => 'Changes made in this list will not be saved until the form is submitted.',
),
);
// Retreive the row's form information.
$wrapper = $form_state['triggering_element']['#ajax']['wrapper'];
$parents = $form_state['triggering_element']['#array_parents'];
$delta = $parents[2];
$row = $form[$parents[0]][$parents[1]][$delta];
// Render the row. This requires rendering it as a table, then stripping away
// unwanted tags in order to leave only the HTML of a table row. Finally,
// all line breaks had to be removed in order to prevent the ajax replace from
// wrapping the output in a div.
$table_row = array(
'#theme' => 'salesforce_mapping_form_table_row',
'#tree' => TRUE,
'#columns' => array_keys($form['salesforce_field_mappings_wrapper']['salesforce_field_mappings']['#header']),
'#row' => $row,
);
$rendered_table = render($table_row);
$rendered_row = str_replace(array(
"\r",
"\n",
), "", $rendered_table);
$commands = array(
// Replace the row.
ajax_command_replace('#' . $wrapper, $rendered_row),
ajax_command_replace("#edit-token-tree", render($form['salesforce_field_mappings_wrapper']['token_tree'])),
ajax_command_replace("#edit-ajax-warning", render($ajax_warn)),
// Set messages if found.
ajax_command_remove('.messages'),
ajax_command_after('#page-title', render($errors)),
);
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}