# HG changeset patch # User Franck Deroche # Date 1232976215 -3600 # Node ID 9d5826d3028d672727f4f68761acfc69576ccd45 # Parent 98642e828c60e9fbf58ab9f5a03fa4f766b49e54 Put the wrapper code after the form has been build and elements replaced diff -r 98642e828c60 -r 9d5826d3028d popups_reference.module --- a/popups_reference.module Wed Jan 21 14:39:42 2009 +0100 +++ b/popups_reference.module Mon Jan 26 14:23:35 2009 +0100 @@ -92,24 +92,19 @@ if ($links) { // Put the nodereference widget and links in an wrapper. // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. - $prefix = '
'; - if (isset($form[$key]['#prefix'])) { - $form[$key]['#prefix'] .= $prefix; - } - else { - $form[$key]['#prefix'] = $prefix; - } - $suffix = '
Add New: ' . implode(', ', $links) .'
'; - if (isset($form[$key]['#suffix'])) { - $form[$key]['#suffix'] = $suffix . $form[$key]['#suffix']; - } - else { - $form[$key]['#suffix'] = $suffix; - } + $form[$key]['#popups_reference_prefix'] = '
'; + $form[$key]['#popups_reference_suffix'] = '
Add New: ' . implode(', ', $links) .'
'; + $form[$key]['#after_build'][] = 'popups_reference_after_build'; } } } +function popups_reference_after_build($form_element) { + $form_element['#prefix'] = $form_element['#popups_reference_prefix'] . $form_element['#prefix']; + $form_element['#suffix'] .= $form_element['#popups_reference_suffix']; + return $form_element; +} + /** * Generates 'Add new...' link * for each allowed content type