It's just a little problem, but I can't explain it quickly (sorry !).

When you're editing a webform's components, you've got a list of existing components and a line to add a new component :
- to choose the type of a new component, each option of the select list is the translated label of corresponding type ;
- for existing components, the displayed type is the translated type, instead of the translated label of the current type.

It's not a problem for users who know HTML tags, but it could be confusing if the final user is a neophyte (maybe only in some languages ?).

What do you think of this suggestion, in webform.components.inc, function _webform_components_form_rows(...) :

// Add each component to a table row.
$row_data = array(
    $indents . filter_xss($component['name']),
    // Current version :
    // t($component['type']),
    // Suggestion to replace the current version :
    (!empty($form['add']['type']['#options'][ $component['type'] ]) ? $form['add']['type']['#options'][ $component['type'] ] : t($component['type'])),
    ($component['value'] == '') ? '-' : $component['value'],
    drupal_render($form['components'][$cid]['cid']) . drupal_render($form['components'][$cid]['pid']) . drupal_render($form['components'][$cid]['weight']),
    l(t('Edit'), 'node/' . $node->nid . '/webform/components/' . $cid, array('query' => drupal_get_destination())),
    l(t('Clone'), 'node/' . $node->nid . '/webform/components/' . $cid . '/clone', array('query' => drupal_get_destination())),
    l(t('Delete'), 'node/' . $node->nid . '/webform/components/' . $cid . '/delete', array('query' => drupal_get_destination())),

This way, we are sure to use the same name at the 2 locations.
Could this be added to the module ? Or does someone have a better solution ?

Thanks for your help !

Members fund testing for the Drupal project. Drupal Association Learn more


quicksketch’s picture

From looking at your code, I can't easily tell what you've changed. Could you either make a patch to show the differences or screenshot before and after your changes?

Teastwood’s picture

Ok sorry, here are a patch (I hope the patch is ok ?) and screenshots before and after changes.

quicksketch’s picture

Title: Prefer the use of the translation of label instead of type ? » Use the translated component title instead running t() on the type
Category: feature » bug

Thanks, haha I meant a screenshot of the interface, but in any case I think it's quite clear now. :)

We actually translate these components already in hook_component_info(), it shouldn't be too hard to pull that information out from there instead of trying to reuse the value from the #options array. Really our use to t() is incorrect here (you shouldn't ever use t() on a variable like this), so I'm moving this to a bug report.

Teastwood’s picture

Pfff, sorry for the screenshots, what was I thinking ?!
Thanks to you !

quicksketch’s picture

Status: Active » Fixed
767 bytes

Committed this patch to both branches to fix this problem. We don't have an easy API function for getting a components label based on its type, but we conveniently already have a key => value list on this page (the "Add" dropdown) so we can use it to pull out the translated labels.

Status: Fixed » Closed (fixed)

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