DrupalBin
Submit Code
About
Recent Posts
TwitterFeed for D4D review
text
rewrite
Module to overrule the save settings of the "new node" form
Code
apidoc
Empty DateTime Object
Fix for listcars_manufacturer.module
listcars_manufacturer.info
listcars_manufacturer.module
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
›
AHAH FAPI Callback Helper
Fix for AHAH FAPI Callback Helper
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
// Example usage. This is an AHAH callback function. function mymodule_ahah() { // Update the form and render only the wrapper inside the "Refund Settings" // fieldset. $form_update_callbacks['some_fieldset][important_data_wrapper'] = array( 'callback' => '_mymodule_form_important_data', 'callback arguments' => array($_POST['some_setting'], $_POST['another_setting'], 'and another one'), ); // Possibly more entries for $form_update_callbacks here. $form_element_to_render = 'some_fieldset][important_data_wrapper'; ahah_helper_render($form_update_callbacks, $form_element_to_render); } /** * This will become ahah_helper.module?! */ function ahah_helper_render($form_update_callbacks = array(), $form_element_to_render) { $form_state = array('submitted' => FALSE); $form_build_id = $_POST['form_build_id']; // Add the new element to the stored form. Without adding the element to the // form, Drupal is not aware of this new elements existence and will not // process it. We retrieve the cached form, add the element, and resave. $form = form_get_cache($form_build_id, $form_state); foreach ($form_update_callbacks as $form_element_name => $settings) { $form_element =& ahah_helper_get_form_element($form, $form_element_name); $form_element = call_user_func_array($settings['callback'], $settings['callback arguments']); } form_set_cache($form_build_id, $form, $form_state); // Rebuild the form. $form += array( '#post' => $_POST, '#programmed' => FALSE, ); $form = form_builder($_POST['form_id'], $form, $form_state); drupal_json(array( 'status' => TRUE, 'data' => drupal_render(ahah_helper_get_form_element($form, $form_element_to_render)), )); } function &ahah_helper_get_form_element(&$form, $parents) { // Allow $parents to be either an array of the element's parents or the name // of an element. if (strpos($parents, ']') !== FALSE) { $parents = explode('][', $parents); } // Recursively seek the form element. if (count($parents)) { $parent = array_shift($parents); return ahah_helper_get_form_element(&$form[$parent], $parents); } else { return $form; } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.