Closed (fixed)
Project:
AHAH helper
Version:
6.x-2.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2009 at 19:14 UTC
Updated:
3 Aug 2009 at 07:20 UTC
With normal FAPI AHAH you can use drupal_json(array( ... )); in your menu callback function in order to return html to the form. What is the equivalent mechanism in AHAH helper?
Comments
Comment #1
20th commentedWith AHAH helper you should use a ahah_helper_path function, as in example ahah_helper_demo.module, which can be found in the module folder.
Like everywhere else AHAH helper also uses drupal_json(array( ... )); in a callback function.
Comment #2
entrigan commentedI thought the idea was that ahah_helper_path() makes the form use the default submit handler rather than a special callback function. So I guess what I am asking is where does the "return drupal_json(...)" go?
Comment #3
20th commenteddrupal_json() is called at the end of ahah_helper_render() function. This is a page callback function registered to the 'ahah_helper/' menu path. This function performs some routine actions and rebuilds the form.
drupal_json() generates output that is sent to the user without modifications.
Comment #4
entrigan commentedThanks for all your help :)
Ok so I found the ahah_helper_render() function, and I see the drupal_json() call. However it looks like it is hardcoded to return theme(status_messages). Is there no way to provide additional HTML ?
Comment #5
20th commentedI think there are two ways to do that, without modifying source code.
You can insert your html directly into the form. You gonna need hook_form_alter or hook_form_ID_alter to do that. Simply add a new element to the form like this:
Whatever you put into #value is rendered without changes. The #weight parameter can control the position of you html in the form. With different #weight values you can put it at the beginning, end, or somewhere in the middle.
Or you can implement you own 'status_messages' hook in your theme, that will output these messages as usual, and add some html when you need it.
This is not the best idea, but still should work.
Comment #6
entrigan commentedThat makes alot of sense. Not sure why I did not think of the hook_form_alter approach. Thanks for the help :)