Increase length 'label' column for components

roginald - July 17, 2007 - 21:20
Project:Webform
Version:5.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

I want to increase the max length of the 'label' for any given webform component. I found that this is stored in the 'webform_component' table as 'name'. This column lists a default value of 128. So this is rather simple to alter. However I don't see in the module or include files where to go to change the max length in the code itself for this particular form element. I tried just changing the database default, emptying cache, then re-editing the form, but the html still displays a max length of 128 for this field. Any suggestions?

#1

roginald - July 17, 2007 - 22:09

So I found in the module file code where I needed to make the change (I hope). Please let me know if this will cause problems, or if there is a more appropriate way to make this change, rather than modyfing the module code.

I added this line:
'#maxlength' => '255',

following this at line 914:
'#title' => t("Label"),

This, along with altering the field definition in the webform_component table for the 'name' field seems to be working.

#2

ebeyrent - November 2, 2007 - 14:43

Any updates on this? I ran into the same issue, and used the method that roginald suggested. I hate hacking the module and the schema, and would love a better way to handle this problem.

#3

ivan.g - November 8, 2007 - 06:12
Version:5.x-1.4» 5.x-1.7
Status:active» fixed

Find this piece of code (approx. line 900 in v.1.7 of webform.module file):

$form['field']['name'] = array(
    '#type' => 'textfield',
    '#default_value' => $currfield['name'],
    '#title' => t("Label"),
    '#description' => t('This is used as a descriptive label when displaying this form element.'),
    '#required' => TRUE,
    '#weight' => -1,
  );

and insert '#maxlength' => '512', to look like this:
$form['field']['name'] = array(
    '#type' => 'textfield',
    '#default_value' => $currfield['name'],
    '#title' => t("Label"),
    '#description' => t('This is used as a descriptive label when displaying this form element.'),
    '#maxlength' => '512',
    '#required' => TRUE,
    '#weight' => -1,
  );

#4

Anonymous - November 22, 2007 - 06:13
Status:fixed» closed

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

#5

suit4 - December 19, 2007 - 13:01
Status:closed» active

For me longer labels would be very helpfull, as far as I use the labels for questions, which might be longer than 255 chars.

#6

LWVMD - December 27, 2007 - 08:11

I'd like to see both a Topic (currently the short label) and a full-length Question for each answer field.

#7

quicksketch - January 27, 2008 - 23:02
Status:active» closed

The label field has been removed entirely and the 'markup' component has been put in place instead. There is no limit on text length for the markup component.

LWVMD, your request should be made a separate issue.

#8

quicksketch - January 27, 2008 - 23:03
Title:Increase length of 'label' in components» Increase length 'label' column for components
Category:support request» feature request
Status:closed» active

Oh I misread the issue. I though we were talking about the 'label' component. Not increasing the Label (or Name) column for all components. I'll make this a feature request.

#9

cardell - March 6, 2008 - 05:48
Version:5.x-1.7» 5.x-2.x-dev

For anyone trying to address this issue in v2.x of webform, you have to make the change in webform_components.inc. Around line 229, you'll see:

  $form['name'] = array(
       '#type' => 'textfield',

Just like in the prior version, you add the following line to that array:
'#maxlength' => '512',

You also need to make the change in the database as noted above:

This, along with altering the field definition in the webform_component table for the 'name' field seems to be working.

#10

quicksketch - March 11, 2008 - 04:25

I'm not really sure why this works for you. While extending the maxlength is definitely necessary, you should also have to update the database column to 255 since it's set to cap at 128 by default. I'd like to add this to webform, so any patches submitted that implement this and an upgrade hook for 2.x (both Drupal 5 and 6) will gladly be applied.

#11

cardell - March 11, 2008 - 09:08

I did have to update the database column. The column changed to a text field in the db (instead of varchar) since I needed a field larger than 255 for some of my questions.

If I can find some time to figure out how to put together the patch and upgrade hook, I would love to help.

#12

quicksketch - April 2, 2008 - 07:41
Status:active» duplicate

The label length has been increased to 255 in this patch: http://drupal.org/node/241319.

 
 

Drupal is a registered trademark of Dries Buytaert.