7 – Add AJAX to an existing form element?

I'm trying to edit a node form element (field_unterbringung). When the user changes the value of an entity reference field (unterbringung), the markup must change from "old markup" to "new markup." But nothing happens. The ajax callback is not even called and drupal_set_message of "ajax callback does not show up" does not show up.

function customizations_form_alter (& $ form, & $ form_state, $ form_id) {
if ($ form_id == "patientprofile_node_form") {
$ form['field_unterbringung']['und'][0]['value']['#prefix']    = & # 39;
& # 39 ;; $ form['field_unterbringung']['und'][0]['value']['#suffix'] = & # 39;& # 39 ;; $ form['field_unterbringung']['und'][0]['value']['#ajax']['callback'] = & # 39; ajax_callback & # 39 ;; $ form['field_unterbringung']['und'][0]['value']['#ajax']['wrapper'] = & # 39; markup_wrapper & # 39 ;; $ form['field_unterbringung']['und'][0]['value']['#ajax']['event'] = & # 39; change & # 39 ;; $ form['field_unterbringung']['und'][0]['value']['#markup'] = "old markup"; drupal_set_message (& # 39;
& # 39 ;. print_r ($ form['field_unterbringung'], TRUE). & # 39;

& # 39;);
}
}

corrected reminder:

ajax_callback function ($ form, & $ form_state) {
drupal_set_message ("activation of ajax callback", "status");
watchdog ("customizations", "reminder reminder ajax");
return form $['field_unterbringung']['und'][0]['value'];
}

UPDATE:

It turns out that when I add the ajax property without [0][‘value’] the Ajax indicator appears.

$ form['field_unterbringung']['und']['#ajax']    = table (
& # 39; callback & # 39; => & # 39; customizations_ajax_callback & # 39;
& # 39; wrapper & # 39; => & # 39; markup_wrapper & # 39;
& # 39; method & # 39; => & # 39; replace & # 39 ;,
& # 39; event & # 39; => & # 39; change & # 39;
)