Mercurial > defr > drupal > popups_reference
comparison popups_reference.module @ 4:9d5826d3028d
Put the wrapper code after the form has been build and elements replaced
author | Franck Deroche <franck@defr.org> |
---|---|
date | Mon, 26 Jan 2009 14:23:35 +0100 |
parents | 98642e828c60 |
children | 990f71344a66 |
comparison
equal
deleted
inserted
replaced
3:98642e828c60 | 4:9d5826d3028d |
---|---|
90 $wrapper_id = 'popups-reference-' . _popups_reference_counter(); | 90 $wrapper_id = 'popups-reference-' . _popups_reference_counter(); |
91 $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); | 91 $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); |
92 if ($links) { | 92 if ($links) { |
93 // Put the nodereference widget and links in an wrapper. | 93 // Put the nodereference widget and links in an wrapper. |
94 // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. | 94 // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. |
95 $prefix = '<div id="'. $wrapper_id .'">'; | 95 $form[$key]['#popups_reference_prefix'] = '<div id="'. $wrapper_id .'">'; |
96 if (isset($form[$key]['#prefix'])) { | 96 $form[$key]['#popups_reference_suffix'] = '<div>Add New: ' . implode(', ', $links) .'</div></div>'; |
97 $form[$key]['#prefix'] .= $prefix; | 97 $form[$key]['#after_build'][] = 'popups_reference_after_build'; |
98 } | |
99 else { | |
100 $form[$key]['#prefix'] = $prefix; | |
101 } | |
102 $suffix = '<div>Add New: ' . implode(', ', $links) .'</div></div>'; | |
103 if (isset($form[$key]['#suffix'])) { | |
104 $form[$key]['#suffix'] = $suffix . $form[$key]['#suffix']; | |
105 } | |
106 else { | |
107 $form[$key]['#suffix'] = $suffix; | |
108 } | |
109 } | 98 } |
110 } | 99 } |
100 } | |
101 | |
102 function popups_reference_after_build($form_element) { | |
103 $form_element['#prefix'] = $form_element['#popups_reference_prefix'] . $form_element['#prefix']; | |
104 $form_element['#suffix'] .= $form_element['#popups_reference_suffix']; | |
105 return $form_element; | |
111 } | 106 } |
112 | 107 |
113 /** | 108 /** |
114 * Generates 'Add new...' link | 109 * Generates 'Add new...' link |
115 * for each allowed content type | 110 * for each allowed content type |