CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Webform, multi-lingual (webform_localization) and CiviCRM
Pages: [1]

Author Topic: Webform, multi-lingual (webform_localization) and CiviCRM  (Read 407 times)

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Webform, multi-lingual (webform_localization) and CiviCRM
September 28, 2015, 05:58:15 am
When creating Drupal webforms for sites in multiple languages (english/french), I usually created two separate nodes with the same configuration and linked then as translations. In the end, they created the same type of activities in CiviCRM, so this duplicaiton of forms wasn't a big deal.

However, I have a project where we have complex forms, with multiple tabs, lots of fields, conditionals, etc. Cloning/translating the node wasn't very practical. If we forgot the smallest changes, the nodes would be out of sync.

So I turned to the "webform_localization" module (https://www.drupal.org/project/webform_localization). It's clever, very practical, but has a few patches in the issue queue that need to be applied for it to work properly (for example: if you want field conditionals to work).

One thing that didn't work, and took me a bit of a while to figure out, is that webform_civicrm processing does not work on the node in the "other" language. We are using "localization by string translation", with both options enabled. This was probably not the best idea, and next time I might go with "localization by sync".

Anyway, for "localization by string translation", I had to patch webform_localization.module so that civicrm processing works:

<pre>
--- a/webform_localization.module
+++ b/webform_localization.module
@@ -227,6 +227,7 @@ function webform_localization_node_view($node, $view_mode) {
     $source_node = node_load($result);
     // We replace the webform with the node translation source.
     $node->webform = $source_node->webform;
+    $node->webform_civicrm = $source_node->webform_civicrm;
 
     // This fool webform_node_view to avoid errors with drafts in between pages.
     $translation_nid = $node->nid;
</pre>

Any other experiences with webform/civicrm/multi-lingual? Any suggestions?
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform, multi-lingual (webform_localization) and CiviCRM
September 28, 2015, 07:42:35 am
Great to hear you got it working. Hopefully the maintainers will respond to your patches or give you commit access.
It doesn't seem wonderful to put coupling inside random modules (explicitly referencing webform_civicrm within webform_localization) but you could argue that the modules are related enough to justify.

FWIW I was able to support the node_clone and node_export modules from webform_civicrm without coupling just by correctly implementing hook_node_load in webform_civicrm, and this looks like it *might* work here as well. If you call node_load on the new node then webform_civicrm will automatically do its thing.
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Webform, multi-lingual (webform_localization) and CiviCRM

This forum was archived on 2017-11-26.