This very simple #ajax customisation to a node form is not working. How can I tell whether the callback has been added? I want to calculate a field if the first field is changed.
function cbi_currency_form_node_bond_edit_form_alter(&$form, FormStateInterface
$form_state, $form_id) {
$form['field_bond_amt_issued']['#ajax'] = [
'callback' => 'cbi_currency_convert_usd',
'event' => 'change',
'wrapper' => 'edit-field-bond-usd-amt-issued-wrapper',
'progress' => [
'type' => 'throbber',
'message' => t('Converting to USD...'),
],
];
$form['field_bond_amt_issued']['#prefix'] = t('checking to see an ajax element.');
}
Take the value from field_bond_amt_issued and calculate a value for field_bond_usd_amt_issued.
The callback is simply
function cbi_currency_convert_usd(array &$form, FormStateInterface $form_state) {
$form['output']['#value'] = 33;
return $form['output'];
}
I don't see any xhr requests when reviewing in the network console in the browser.