- Index
- » General
- » General discussion
- » Can't AHAH-ify cck field in form with...
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?
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..
- Index
- » General
- » General discussion
- » Can't AHAH-ify cck field in form with...
Board Info
- Board Stats:
- Total Topics:
- 2896
- Total Polls:
- 0
- Total Posts:
- 23
- Dormant:
- User Info:
- Total Users:
- 52
- Newest User:
- Name
- Members Online:
- 0
- Guests Online:
- 815
- Online:
- There are no members online
Forum Legend:
- Topic
- Nový
- Locked
- Sticky
- Active
- New/Active
- New/Locked
- New Sticky
- Locked/Active
- Active/Sticky
- Sticky/Locked
- Sticky/Active/Locked