Allow Webform form location to be reordered through CCK field ordering

omo - March 25, 2009 - 19:32
Project:Webform
Version:6.x-2.8
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

In my setup (including CCK) the description of a webform is rendered below the form not above. I did not find another solution but to change the weight of the $node->content['webform'] field to make sure it's higher than any other cck field. This should be clearly fixed more properly by the module itself by assigning a weight according the weight of the other node fields. The attached patch should help in most cases for the meantime.

AttachmentSize
webform.module.patch340 bytes

#1

cdale - March 25, 2009 - 20:55

A better solution would be use hook_content_extra_fields_alter. Something like:

<?php
function webform_content_extra_fields_alter(&$extra, $type_name) {
  if (
$type_name == 'webform') {
   
$extra['webform'] = array(
     
'label' => t('Webform'),
     
'description' => t('webform display'),
     
'weight' => 1,
    );
  }
}
?>

I haven't actually tested this code myself, but I've done something similar in other modules. This way, you can adjust the weight on the webform content type page via CCK.

#2

quicksketch - March 25, 2009 - 21:12

I agree, cdale's approach would be preferable if we're going to be making changes to the weights.

#3

matulis - July 14, 2009 - 19:37

Thank You, CDALE!
Tested and works smoothly.

#4

Digital Deployment - August 22, 2009 - 17:34
Status:needs work» reviewed & tested by the community

Tested cdale's recommendation and it worked great! I recommend that it be committed to webform. I've rolled a patch of the changes.

AttachmentSize
webform-field-weights.patch 511 bytes

#5

vegancheesesteak - August 22, 2009 - 19:12

This is extremely useful! Thank you!

#6

omo - September 7, 2009 - 17:32

Wow, I didn't knew there's such a elegant solution. Thanks cdale.

#7

jkristos - November 4, 2009 - 20:48

I think I'm missing something obvious.
With cdale's above code in template.php, where should I be able to set the weight of that field?

#8

quicksketch - November 6, 2009 - 00:19
Version:6.x-2.6» 6.x-2.8
Category:bug report» feature request
Status:reviewed & tested by the community» fixed

Thanks, I cleaned up the documentation and comments and committed to the Drupal 6 2.x version.

AttachmentSize
webform_content_extra_fields.patch 833 bytes

#9

quicksketch - November 6, 2009 - 00:21

jkristos, This is a change to the module file, not to your theme. After applying the patch, you can reorder the field through CCK's interface for ordering fields at admin/content/node-type/webform/fields.

#10

quicksketch - November 6, 2009 - 02:40
Title:"Description" aka body rendered below the form not above» Allow Webform form location to be reordered through CCK field ordering

#11

System Message - November 20, 2009 - 02:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.