2

Inside of a hook_form_alter function, I want to leverage the #ajax property to modify/update database tables without leaving the form... In other words, I want the user to be able to fill in the field and either "tab", "click" or "enter" and have ajax respond.

The response should be an update of that field being displayed as well as an update to the DB...

If I can get the call back to wakeup, the DB call is easy. And hopefully the form displays that new data. Code I have so far is:

$form['license'] = array(
  '#type' => 'textfield',
  '#title' => t('License'),
  '#size' => 20,
  '#default_value' => 'default license',
  '#required' => FALSE,
  '#weight' => 10,
  '#ajax' => array(
    '#callback' => 'license_fillin_js',
    '#event' => 'change',
    .
    .
    .

  ),

So far, nothing seems to be waking up the callback.

This is probably very simple! Right?

2

change it to and then try again.

$form['license'] = array(
  -
  -
  '#ajax' => array(
    'callback' => 'license_fillin_js',
    'event' => 'change',
    .
    .
    .

  ),

As an example you can check this link

| improve this answer | |
  • Thank you for fast response! I don't see anything different in your code example... – sea26.2 Oct 10 '13 at 22:18
  • @user908998 why you are putting '#' before callback and event – arpitr Oct 10 '13 at 22:22
  • Bingo... I completely didn't notice that I did that. Thank you! – sea26.2 Oct 10 '13 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.