Mercurial > defr > drupal > noderef_view
changeset 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 | b4c1e3d5d5ce |
files | noderef_view.module |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/noderef_view.module Fri Jan 23 18:57:45 2009 +0100 +++ b/noderef_view.module Mon Jan 26 12:28:09 2009 +0100 @@ -112,19 +112,20 @@ if (is_array($field) && $field['type'] == 'nodereference') { $link = _noderef_view_get_link($field); if (!empty($link)) { - $suffix = $link; - if (isset($form[$key]['#suffix'])) { - $form[$key]['#suffix'] = $suffix . $form[$key]['#suffix']; - } - else { - $form[$key]['#suffix'] = $suffix; - } + $form[$key]['#links'] = $link; + $form[$key]['#after_build'] = array('noderef_view_add_link'); return TRUE; } } return FALSE; } +function noderef_view_add_link($form_element) { + $form_element['#prefix'] = "<div class='noderef-view-wrapper'>" . $form_element['#prefix']; + $form_element['#suffix'] .= $form_element['#links'] . '<span class="clear"></span></div>'; + return $form_element; +} + /** * Création d'un lien vers une éventuelle vue associé au champ. *