0

I have a form build with the webform module. When text is entered in the input box in this case webform component 2 I want it to execute a ajax function and put data in a div. However this is not working at the moment. When i connect the ajax to $form['actions']['submit'] it does work.But i want it to be stuck to the input box not the submit function. The function is placed in the hook_form_alter.

$form['#node']->webform['components'][2]['#ajax'] = array(
  'callback' => 'callback function',
  'wrapper' => '#foo',
  'method' => 'replace',
  'effect' => 'fade',
);
0

I figured out you cannot attach ajax to webform components you need to add them to $form['submitted']

$form['submitted']['TEXTFIELDNAME']['#ajax'] = array(
  'callback' => 'callback function',
  'wrapper' => '#foo',
  'method' => 'replace',
  'effect' => 'fade',
);

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.