I want to create a ctools modal popup when a button is pressed.

function custom_form( $form, &form_state ) {
  $form['btn'] = array(
    '#type' => 'button',
    '#value' => t('add'),
    '#executes_submit_callback' => FALSE,
    '#ajax' => array(
      'callback' => 'custom_callback',

function custom_callback() {

  ctools_modal_render( 'Error', 'Error Message');

I only get the alert message with the un-rendered ajax response. How can get I this response displayed in rendered format in modal?

1 Answer 1


Checkout Documentation on: http://api.drupal.org/api/drupal/includes!ajax.inc/7 or: http://drupal.org/node/1635198#comment-6120546 on how to render drupal messages.

For more Information about ctools modal you may check: Example to display webforms (webform.module) within CTools modal windows

Or what about a tutorial like: "Ajax modal windows, the easy way"

  • 1
    I checked with all those links prior to posting my question.For the example in the last tutorial modal window is invoked via text link in which the ctools-in-modal class is added to the attributes. I need to know a method, by using which I can add same attribute to ajax button.
    – tharumax
    Commented Aug 19, 2012 at 23:29
  • Maybe it's an option to just theme the link as a button.
    – LarS
    Commented Aug 20, 2012 at 12:56

Your Answer

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

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