summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--content.module35
2 files changed, 22 insertions, 14 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 7969845..54820dd 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,6 +39,7 @@ should be enough, though.
- #371306 fix duplicate HTML when using the JS-'add more' button.
- #370004 by dopry - Fix JS-'add more' button breaking fielfield's AHAH upload.
- #374213 by rpanna - Fieldgroup: All field instances removed their groups when one instance is deleted from a content type.
+- #356158 by markus_petrux - Fix more (hopefully all ?) cases of bogus d-n-d reordering of 'pseudo-fields'.
CCK 6.x-2.1
===========
diff --git a/content.module b/content.module
index 0a73739..178ad06 100644
--- a/content.module
+++ b/content.module
@@ -420,16 +420,8 @@ function content_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
// Special case for 'view' op, we want to adjust weights of non-cck fields
// even if there are no actual fields for this type.
if ($op == 'view') {
- foreach ($type['extra'] as $key => $value) {
- // Some core 'fields' use a different key in node forms and in 'view'
- // render arrays.
- if (isset($value['view']) && isset($node->content[$value['view']])) {
- $node->content[$value['view']]['#weight'] = $value['weight'];
- }
- elseif (isset($node->content[$key])) {
- $node->content[$key]['#weight'] = $value['weight'];
- }
- }
+ $node->content['#pre_render'][] = 'content_alter_extra_weights';
+ $node->content['#content_extra_fields'] = $type['extra'];
}
}
}
@@ -445,13 +437,28 @@ function content_form_alter(&$form, $form_state, $form_id) {
// Merge field widgets.
$form = array_merge($form, content_form($form, $form_state));
}
- // Adjust weights for non-CCK fields.
- foreach ($type['extra'] as $key => $value) {
- if (isset($form[$key])) {
- $form[$key]['#weight'] = $value['weight'];
+ $form['#pre_render'][] = 'content_alter_extra_weights';
+ $form['#content_extra_fields'] = $type['extra'];
+ }
+}
+
+/**
+ * Pre-render callback to adjust weights of non-CCK fields.
+ */
+function content_alter_extra_weights($elements) {
+ if (isset($elements['#content_extra_fields'])) {
+ foreach ($elements['#content_extra_fields'] as $key => $value) {
+ // Some core 'fields' use a different key in node forms and in 'view'
+ // render arrays. Check we're not on a form first.
+ if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
+ $elements[$value['view']]['#weight'] = $value['weight'];
+ }
+ elseif (isset($elements[$key])) {
+ $elements[$key]['#weight'] = $value['weight'];
}
}
}
+ return $elements;
}
/**