comparison noderef_view.module @ 3:9372c6448311

Add the link in an after_build callback to be a lot more robust. This way, we act after the noderefence fields got transformed into normal widgets by the form processing code. We can thus be pretty sure that the code we put in there will end up where we expect it too.
author Franck Deroche <franck@defr.org>
date Mon, 26 Jan 2009 12:28:09 +0100
parents 25a0c2fcbcfb
children 4fc2f22efcdf
comparison
equal deleted inserted replaced
2:25a0c2fcbcfb 3:9372c6448311
110 */ 110 */
111 function noderef_view_alter_item(&$form, $key, $field) { 111 function noderef_view_alter_item(&$form, $key, $field) {
112 if (is_array($field) && $field['type'] == 'nodereference') { 112 if (is_array($field) && $field['type'] == 'nodereference') {
113 $link = _noderef_view_get_link($field); 113 $link = _noderef_view_get_link($field);
114 if (!empty($link)) { 114 if (!empty($link)) {
115 $suffix = $link; 115 $form[$key]['#links'] = $link;
116 if (isset($form[$key]['#suffix'])) { 116 $form[$key]['#after_build'] = array('noderef_view_add_link');
117 $form[$key]['#suffix'] = $suffix . $form[$key]['#suffix'];
118 }
119 else {
120 $form[$key]['#suffix'] = $suffix;
121 }
122 return TRUE; 117 return TRUE;
123 } 118 }
124 } 119 }
125 return FALSE; 120 return FALSE;
121 }
122
123 function noderef_view_add_link($form_element) {
124 $form_element['#prefix'] = "<div class='noderef-view-wrapper'>" . $form_element['#prefix'];
125 $form_element['#suffix'] .= $form_element['#links'] . '<span class="clear"></span></div>';
126 return $form_element;
126 } 127 }
127 128
128 /** 129 /**
129 * Création d'un lien vers une éventuelle vue associé au champ. 130 * Création d'un lien vers une éventuelle vue associé au champ.
130 * 131 *