The advanced help topic nodes module generates its injection IDs like this:
// In hook_form_alter
foreach ($form as $id=>$element) {
$form[$id] = advanced_help_topic_nodes_for_forms_add_help_icons($id,$element,$form_id);
$topic_id = $form_id . "--" . $id;
}
The Help Inject does it like this:
function helpinject_get_helpkey($form_id, $form_element) {
$clone = array('type' => $form_element['#type']);
if (isset($form_element['#title'])) {
$clone['title'] = $form_element['#title'];
}
$hash = md5(serialize($clone));
return "{$form_id}-{$hash}";
}
The Help Inject's method is a bit subtler, perhaps to its detriment. It takes the #type and #title and MD5's them, plus a concatenation with the $form_id.
The FAPI is weird and diverse enough that I think I have to do an experiment to see how each of these approaches behave on different Drupal forms before I can make a decision.
Comments
Comment #1
robertdouglass commentedI did an experiment and have come up with this approach, which I'm implementing in the Help Inject module.
Comment #2
robertdouglass commented