function party_primary_fields_source_table_submit in Party 7
Submission handler for the add/remove source buttons.
1 string reference to 'party_primary_fields_source_table_submit'
- PartyPrimaryFields::sourceForm in includes/
party.primary_fields.inc - Set up a source form under the given element.
File
- ./
party.admin.inc, line 267 - Admin page callback file for the party module.
Code
function party_primary_fields_source_table_submit(&$form, &$form_state) {
// Get our element.
$parents = array_slice($form_state['triggering_element']['#array_parents'], 0, -2);
$element = drupal_array_get_nested_value($form, $parents);
// Get our values
$values = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
// If removing, clear the source item.
if (end($form_state['triggering_element']['#parents']) == 'remove') {
$key = $form_state['triggering_element']['#parents'][count($form_state['triggering_element']['#parents']) - 2];
unset($values[$key]);
}
elseif ($form_state['triggering_element']['#parents'][0] == 'add_source_submit') {
// Get hold of our new source.
$key = $form_state['values']['add_source_property'];
$source = array(
'weight' => 0,
);
list($source['data_set'], $source['property'], $source['value']) = explode(':', $key . ':');
// Insert the source
$values[$key] = $source;
}
// Store our updated value.
drupal_array_set_nested_value($form_state['values'], $element['#parents'], $values);
$form_state['rebuild'] = TRUE;
}