欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Drupal 6 Form API ajax

shiping1 的头像

下面是自己亲自做的例子 有大用
function tijiaobijiCallback(){
         //$block = module_invoke('shipingzhongcustomthree', 'block', 'block', 'bijibyjiaocheng-block_2');
//代码在模块中好像不能正常运行
         //$block =  views_get_view_result('bijibyjiaocheng','block-1');

//代码在模块中好像不能正常运行

         //views_embed_view('bijibyjiaocheng','block-1');

//代码在模块中好像不能正常运行



         $view = views_get_view('bijibyjiaocheng');

//代码在模块中可以正常运行

         $content = $view->execute_display('block-1');

//代码在模块中可以正常运行

         drupal_json(array('status'=>TRUE,'data'=>$content));
     }

Drupal 6 Form API: using #ajax

Hi,
I have very simple form with one ajax callback. I did it according example on official Form API reference page. I don't understand why it doesn't work.

<?php
function wishlist_status_form($form_state) {
$form['status'] = array(
   
'#type' => 'textfield',
   
'#title' => 'Status',
   
'#suffix' => '<div id="my-wrapper"></div>',
  );

$form['ajax-submit'] = array(
   
'#type' => 'submit',
   
'#ajax' => array(
       
'callback' => 'wishlist_status_change',
       
'wrapper' => 'my-wrapper',
    ),
   
'#value' => t('Save'),
  );
return
$form;
}
function
wishlist_status_change($form, $form_state) {
   
dpm($form_state, 'state callback');
    return
'test';
}

?>

When I click the button Save, it reloads all page and doesn't go through function wishlist_status_change. What am I doing wrong?
thanks for any help
Tomas

Comments

I have already find it out. #ajax element is only from Drupal 7. In D6 I have to use #ahah attribute.

plz provide full documention code i have need it..........

In poll module they made good use of #ahah for adding dynamic rows for options. Look @it . Otherwise go though the http://ericlondon.com/tag/ahah and Introduction to AHAH Forms in Drupal

来自 https://drupal.org/node/1235710

普通分类: