Commit 4991accd authored by ccarigna's avatar ccarigna
Browse files

Removed previous AJAX code

parent 4647fd4d
......@@ -98,67 +98,11 @@ function uw_ct_event_form_uw_event_node_form_alter(&$form, &$form_state, $form_i
// Remove the 'delete this location' checkbox on the edit form
$form['field_event_location']['und'][0]['#after_build'][] = 'uw_ct_event_remove_location_delete';
// Add Div Wrapper around form so the AJAX handler can replace the complete form within it
// Need to do this if we need to update more then one field which we do
// Add Div Wrapper around form so the javascript knows where to add the location lookup dropdown
$form['field_event_location']['#prefix'] = '<div id="uw_event_location">';
$form['field_event_location']['#suffix'] = '</div>';
/* no longer use Drupal internal AJAX
// Have to set the AJAX callback parameter on the field language instance value
// Also see this issue for some extra insight: http://drupal.org/node/1024962
// Specifically on setting another form field value - as we need to below.
$form['field_event_location_lookup']['und']['#ajax'] = array(
// #ajax has two required keys: callback and wrapper.
'callback' => 'uw_ct_event_load_location_details', // 'callback' is a function that will be called when this element changes.
'wrapper' => 'uw_event_location', // 'wrapper' is the HTML id of the page element that will be replaced.
'method' => 'replace',
'effect' => 'fade',
);
// An AJAX request calls the form builder function for every change.
// We can change how we build the form based on $form_state.
if (!empty($form_state['values']['field_event_location_lookup']['und'][0]['nid'])) {
$node = node_load($form_state['values']['field_event_location_lookup']['und'][0]['nid']);
unset($form_state['input']['field_event_location']['und'][0]['name']);
$form['field_event_location']['und'][0]['#default_value']['name'] = $node->title;
unset($form_state['input']['field_event_location']['und'][0]['additional']);
$form['field_event_location']['und'][0]['#default_value']['additional'] = $node->field_location_details['und'][0]['additional'];
unset($form_state['input']['field_event_location']['und'][0]['street']);
$form['field_event_location']['und'][0]['#default_value']['street'] = $node->field_location_details['und'][0]['street'];
unset($form_state['input']['field_event_location']['und'][0]['city']);
$form['field_event_location']['und'][0]['#default_value']['city'] = $node->field_location_details['und'][0]['city'];
unset($form_state['input']['field_event_location']['und'][0]['province']);
$form['field_event_location']['und'][0]['#default_value']['province'] = $node->field_location_details['und'][0]['province'];
unset($form_state['input']['field_event_location']['und'][0]['postal_code']);
$form['field_event_location']['und'][0]['#default_value']['postal_code'] = $node->field_location_details['und'][0]['postal_code'];
unset($form_state['input']['field_event_location']['und'][0]['country']);
$form['field_event_location']['und'][0]['#default_value']['country'] = $node->field_location_details['und'][0]['country'];
}
$form['field_event_location']['und'][0]['#default_value']['locpick']['user_latitude'] = '49.001';
// */
}
/* AJAX Callback function defined in uw_ct_contact_form_contact_node_form_alter
* Must not modify the form in the AJAX callback - just return what to replace
*
function uw_ct_event_load_location_details($form, $form_state) {
// The form has already been submitted and updated. We can return the replaced
// item as it is.
return $form['field_event_location'];
}
// */
/**
* Remove the delete checkbox from location element.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment