Saturday, Jul 27th

Last update12:45:09 PM GMT

  • Create an account
    *
    *
    *
    *
    *
    Fields marked with an asterisk (*) are required.
Add Announcement Here

Can't AHAH-ify cck field in form with hook_form_alter()

Can't AHAH-ify cck field in form with hook_form_alter()

Hi Guys,

I've come to a situation where I have to override the original node_form for a specific content type and add AHAH to one of my select list. However my code didn't work out, and I can't see the throbber icon that's supposed to show up when I change selection in the select list. One word, it's not AHAH-ified. Here is the part of code:

function my_module_form_alter(&$form, $form_state, $form_id) {
...
switch ($form_id) {
case 'my_content_type_node_form': //The node form for the content type I wish to override
$form['my_field_id']['#ahah'] = array( //id of the cck field on which I want to enable AHAH
'event' => 'change',
'path' => 'my_module/js',
'wrapper' => 'ahahdiv' //The div wrapper I create for AHAH change just for testing purpose
);
break;
...
}

function my_module_menu() {
$items['my_module/js'] = array(
'page callback' => 'my_module_form_js',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK
);
return $items;
}

function my_module_form_js() {
return drupal_json(array('status' => TRUE, 'data' => "I see AHAH"));
}

When I enabled my module and try creating a new content of that type I want, I changed the select list and nothing happened. I have tried my best debugging it but the result stayed the same. I am kinda desperate now so I'd appreciate any input from you guys.. Thanks in advance.

P.S. I just noticed select list created by cck field has the "#type" property "optionwidget_select" rather than "select". Is that the reason why AHAH is rejecting this field since it can not recognize its type?

Guest
Guest
useravatar
Offline
Posts
User info in posts
Administrator has disabled public posting

Re: Can't AHAH-ify cck field in form with hook_form_alter()

Eh alright I guess I found it being exactly my last guess.. An ordinary select list widget I added in at form in form_alter() performed AHAH beautifully.. If anyone can suggest me the way to perform AHAH on cck fields that'd be awesome..

Guest
Guest
useravatar
Offline
Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
4654
Total Polls:
0
Total Posts:
1109
Dormant:
User Info:
 
Total Users:
17
Newest User:
Sukran
Members Online:
0
Guests Online:
1639

Online: 
There are no members online

Forum Legend:

 Topic
 Yeni
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked

Bizi Takip Ediyor musunuz ?

Biz neredeyiz ?

  • Gökkuşağı Mahallesi 1104. Sok. 19/24 Balgat - Çankaya - Ankara

  • Tel: (+90) 505 8894038

www.muhder.com