Hello,
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]['mandatory']),
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 !
Comment | File | Size | Author |
---|---|---|---|
#5 | webform_component_list_translated.patch | 767 bytes | quicksketch |
#2 | webform.components.inc_.diff | 717 bytes | Teastwood |
#2 | webform-before.png | 65.97 KB | Teastwood |
#2 | webform-after.png | 78.98 KB | Teastwood |
Comments
Comment #1
quicksketchFrom 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?
Comment #2
Teastwood CreditAttribution: Teastwood commentedOk sorry, here are a patch (I hope the patch is ok ?) and screenshots before and after changes.
Comment #3
quicksketchThanks, 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.
Comment #4
Teastwood CreditAttribution: Teastwood commentedPfff, sorry for the screenshots, what was I thinking ?!
Thanks to you !
Comment #5
quicksketchCommitted 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.