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?

Comments

roginald’s picture

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.

ebeyrent’s picture

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.

ivrh’s picture

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,
  );
Anonymous’s picture

Status: Fixed » Closed (fixed)

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

suit4’s picture

Status: Closed (fixed) » 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.

LWVMD’s picture

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

quicksketch’s picture

Status: Active » Closed (fixed)

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.

quicksketch’s picture

Title: Increase length of 'label' in components » Increase length 'label' column for components
Category: support » feature
Status: Closed (fixed) » 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.

cardell’s picture

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.

quicksketch’s picture

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.

cardell’s picture

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.

quicksketch’s picture

Status: Active » Closed (duplicate)

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

DrupalDan’s picture

Version: 5.x-2.x-dev » 7.x-3.17
Category: feature » support
Status: Closed (duplicate) » Active

Hi guys,

Can anyone tell me how to increase the max length of the label in port 7?

Thanks in advance!

quicksketch’s picture

Version: 7.x-3.17 » 5.x-2.x-dev
Category: support » feature
Status: Active » Closed (duplicate)

Please do not reopen ancient issues. The changes in the patches in #241319: Increase webform_component.name to 255 should provide you some guidance.