Flipkart

Wednesday, June 8, 2011

Ajax Module With Image Button Drupal

If you are using Ajax module for Drupal Forms which having image button, then you can not submit the form.
To fix that kind of issue then we have to use  '#button_type' => 'submit ajax-trigger', attribute to submit button. Below is the sample code...

$path = drupal_get_path('theme', 'tradenet').'/images/image_button.png';
      $form['#ajax'] = array(
        'enabled' => TRUE
      );
      $form['submit'] = array(
             '#type' => 'image_button',
             '#access' => 1,
             '#button_type' => 'submit ajax-trigger',
             '#src'=>$path,
             '#ajax' => array('submitter' => TRUE ),

            
          );

2 comments:

  1. Hey,

    I'm having the exact problem right now. I tried your code but its not working for me - my ajax still doesn't return anything.

    Are you sure your line
    '#ajax' => array('submitter' => TRUE),
    is correct ? I search for such in the doc but there is nothing about this (http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7)

    Thanks

    ReplyDelete
  2. Hi, yeah this post is really pleasant and I have learned lot of things from it on the topic of blogging. thanks.

    ReplyDelete