Wednesday, Apr 30th

Last update12:32:47 AM GMT

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

Impressum

  • office of arts GmbH
    Seltersstrasse 1
    12305 Berlin
  • Büro c/o SpeakEazy, Kulmer Straße 20a, 10783 Berlin
  • Telefon :  0175 721 30 35 Thomas Frenz
                    0160 959 55 184 Boris Hampel
                
  •  Handelsregister : HRB 118870 B
  • Ust.ID : DE264910410
  • Geschäftsführer : Thomas Frenz
  • Mailadresse : tf[at]officeofarts.de
You are here