I have created one drupal form as following :

function add_action_item_and_alert_createalert_form($form_state){

     $alertahah = 'alertwithahah';

     $form = array();   
$form['manual_alert_fieldset'] = array(
        '#title' => 'New alert for reservation', 
        '#id' => 'manual_alert_fieldset',   
        '#type' => 'fieldset',
        '#collapsible' => TRUE

    $form['booking_id'] = array(
        '#id' => 'booking_id',  
        '#type' => 'hidden',
        '#value' => $_GET['bid'],

    $form['manual_alert_fieldset']['manual_alert_note'] = array(
        '#id' => 'manual_alert_note',
        '#title' => t('Enter Alert Note'),  
        '#type' => 'textarea',

    $form['manual_alert_fieldset']['submitalert'] = array(
        '#type' => 'submit',
                '#ahah' => array(
                'wrapper' => $alertahah,
                'method' => 'append'

        '#value' => t('Create New Alert'),

   $form['#redirect'] = FALSE;

    return $form;

On callback function of the above form, I want to render another form using

    $html_form = drupal_get_form('fsaclientservice_alert_comment_form',$alert_id);
 print drupal_json(array('status' => TRUE, 'data' => $html));

The above code is working fine and rendering another form without refreshing the page.

The only problem is that the Form which I am rendering ('fsaclientservice_alert_comment_form' ) is having #ahah field and it should add html to a page on submit button of the form without refresh.

Currently the action of a comment_form which is rendered using ajax is wrong and it not going to the callback function that form and page get refreshed on submit button of comment_form(generated by ajax).

I have tried to change the action like below :

$html .= str_replace("/admin/fsacs/fsaclientservice/action-items-and-alerts/createalert", '/fsaclientservice/viewreservation?bid=63822', $html_form);

But still the page is get refreshed.

Can I render a form with #ahah in a callback of one form ?

  • Are you using Drupal 6 ? – 2pha Apr 22 '15 at 7:23
  • Yes I am using D6 and thats why I preferred ahah – Akki Apr 22 '15 at 7:26

Your Answer

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

Browse other questions tagged or ask your own question.