If you use CCK to 'manage fields' and drag the 'body' around anywhere (or make any change at all AFAIK) there's a good chance that the form 'weights' set when form_alter added its field will become totally nonsensical.

Specifically, my 'body' field ended up with #weight=36 and the reptag element with weight 1 was the first thing on my node edit pages. two screens above even the title. It seems to break about half of the contrib node elements I'm using. Reptag is the safest to start fixing though ...

After tracing deep deep deep, I discovered

/**
 * Retrieve the user-defined weight for non-CCK node 'fields'.
 *
 * CCK's 'Manage fields' page lets users reorder node fields, including non-CCK
 * items (body, taxonomy, other hook_nodeapi-added elements by contrib modules...).
 * Contrib modules that want to have their 'fields' supported need to expose
 * them with hook_content_extra_fields, and use this function to retrieve the
 * user-defined weight.
 */
function content_extra_field_weight($type_name, $pseudo_field_name) {

So the fix (for CCKs destructiveness) is:

/**
* Implementation of hook_content_extra_fields.
*
* Informations for the positioning of non-CCK 'node fields' defined in core.
* @see content_extra_field_weight()
*
* reptag_form_alter() sets weight to 1 - which makes sense, but cck then
* scambles the node edit form when the 'body' is repositioned.
*/
function reptag_content_extra_fields($type_name) {
$extra = array();

if (variable_get('reptag_showhelp', 1)) {
$extra['reptag_help'] = array(
'label' => t('Reptag help'),
'weight' => 1,
);
}
return $extra;
}
?>
It's a pain, but it works. You can now drag the reptag info down to the right place on the CCK content type field management page.
:-{

Patch attached.
(patch also repairs a minor access problem that blocked users with only access to their own tags (not sitewide tags) from accessing the config screens at all.)

It's a harmless patch, but I'll let it mature in the queue for a while. anyone that tries it can RTBC it and I'll commit.

CommentFileSizeAuthor
reptag-CCK_field_ordering.patch1.46 KBdman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dman’s picture

Ug, miss-spelled php in the code paste above or something


/**
 * Implementation of hook_content_extra_fields.
 *
 * Informations for the positioning of non-CCK 'node fields' defined in core.
 * @see content_extra_field_weight()
 * 
 * reptag_form_alter() sets weight to 1 - which makes sense, but cck then
 * scambles the node edit form when the 'body' is repositioned.
 */
function reptag_content_extra_fields($type_name) {
  $extra = array();

  if (variable_get('reptag_showhelp', 1)) {
    $extra['reptag_help'] = array(
      'label' => t('Reptag help'),
      'weight' => 1,
    );
  }
  return $extra;
}
dman’s picture

Status: Needs review » Fixed

Committed, plus some other little stuff - I found a huge inefficiency in reptag_blocks calling views_block.
I think we are about due for a stable 6 release, eh?
There's been no big problems that I can see. Issue queue is mostly support requests it seems.

Status: Fixed » Closed (fixed)
Issue tags: -CCK, -order, -form_alter

Automatically closed -- issue fixed for 2 weeks with no activity.