2

I've tried to add the property "#ajax" to email field but It dosen't work, I've tried all this :

$form["field_user_email"]['#ajax'] = array(
      'callback' => 'user_ajax_check',
      'wrapper' => 'usercheck',
      'effect' => 'fade',
  );

$form["field_user_email"]['und']['#ajax'] = array(
      'callback' => 'user_ajax_check',
      'wrapper' => 'usercheck',
      'effect' => 'fade',
  );
$form["field_user_email"]['und'][0]['#ajax'] = array(
      'callback' => 'user_ajax_check',
      'wrapper' => 'usercheck',
      'effect' => 'fade',
  );

1 Answer 1

3

If the field is provided by the Email Field module it'll probably be:

$form["field_user_email"]['und'][0]['email']['#ajax'] = array(...

If it's just a standard text field it will be:

$form["field_user_email"]['und'][0]['value']['#ajax'] = array(...
4
  • It's working now I can see the ajax , but when it performed I have lot of missing form element , can you help please , you are a life saver
    – sel_space
    Sep 4, 2012 at 16:59
  • 1
    I'd guess it's something to do with the AJAX wrapper, and the element you're actually wrapping (you're probably wrapping the whole field array and not just the individual element). Can you post your AJAX callback code along with the code you're using now in the form alter function, either in your question or a new one (new one would probably be better, it would separate the things out so it's more helpful fo future users)?
    – Clive
    Sep 4, 2012 at 17:17
  • thanx that helped me a lot
    – sel_space
    Sep 4, 2012 at 17:34
  • I create a field in article content type,it's type is text ,I really test all of above methods in mycustommodule_form_alter, really not working for me.but my method work correctly. :(
    – Yuseferi
    Sep 4, 2012 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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