| 7 dbtng_example.module | dbtng_example_form_update_callback($form, $form_state) |
| 8 dbtng_example.module | dbtng_example_form_update_callback($form, $form_state) |
AJAX callback handler for the pid select.
When the pid changes, populates the defaults from the database in the form.
Related topics
1 string reference to 'dbtng_example_form_update_callback'
File
- dbtng_example/
dbtng_example.module, line 540 - This is an example outlining how a module can make use of the new DBTNG database API in Drupal 7.
Code
function dbtng_example_form_update_callback($form, $form_state) {
$entry = $form_state['entries'][$form_state['values']['pid']];
// Setting the #value of items is the only way I was able to figure out
// to get replaced defaults on these items. #default_value will not do it
// and shouldn't.
foreach (array('name', 'surname', 'age') as $item) {
$form[$item]['#value'] = $entry->$item;
}
return $form;
}
Login or register to post comments