When using "single webform across translation set" the webform tab on a translation is useless.
From UI point of view this is very confusing.

I saw 2 ways to fix this:
- Overriding the load function in hook_menu_local_tasks_alter so that the webform tabs don't show up.
-> cons: slow and ugly menu code, not seeing the webform tab might be confusing to the user

- A simple goto on all webform tabs, that redirect to the respective tab of original translation
-> cons: won't *just* work for 3rd party webform contrib modules.

I chose the 2nd option
Patch coming up

Comments

rv0’s picture

Status: Needs work » Active
StatusFileSize
new4.33 KB

It's not the cleanest code (lots of code repetition), but it gets the job done until some utility functions are created for this job.

also includes the 1 line fix from #1474946: Breaks functinality for untranslated content. because the patch is pulled straight from my development site.

rv0’s picture

Status: Active » Needs review

Changing to needs review.
(patch created at Coworks)

rv0’s picture

Status: Needs review » Needs work

hmm thinking about it.. There's still the problem for the results tab too.

guess thats back to the drawing board.
suggestions welcome!

GDrupal’s picture

@rv0: This is a interesting issue.. We have to think more about it. What about this... We replace the webform tab for a single menu entry that redirects to the source webform we can call it "Source Webform" or something like that.

rv0’s picture

GDrupal: sounds like a proper solution to me. Can't think of anything better

basicly:
- change to a custom load function for all webform paths (using regex or substr, slow but gets cached anyway) in hook_menu_alter
- put the logic in there to remove the tabs
- add a 2nd tab with a second load function that links to "Source Webform"

I'll have a look later.. First I'm working on integration between webform_localization and webform_template as I need this urgently.

GDrupal’s picture

@rv0: Sound Good! Let me know if I can assist you in anything, will be my pleasure!

dragonwize’s picture

Can you further explain the core issue here?

If you are using the string translation method and not the content translation method then you should not have a "translation set". There should be only 1 node so why are you trying to redirect from translated nodes?

It sounds like you are trying to mix the options available in a bad way as if you are using content translation your webform results and options will be different per language and will need the webform tab to see and use those features.

rv0’s picture

dragonwize:

Keep a single webform across a translation set.
When you use the i18n module to translate webform component strings, you may like to keep a single webform to attach on each node from a translation set.

Nobody is mixing up things, imagine multiple nodes in a set, and only one webform. This is what the option enables. The nodes can contain a lot of fields that need specific node-based translation, but the webform needs to be the same (in my case, events with subscription webform).
Ideally Entity translation would solve this in a lot of cases, but it's not a stable enough option today. (OT)

dragonwize’s picture

No that is mixing it up. There are two options available that you can choose:

1. Use a single node and use the i18n_strings module to translate the labels etc. to translate the form on display the same way a menu item is. You miss out on node title translation with this method but if you don't need it that is fine.

2. (This is the method you quoted above though it is badly worded.) You can use content translation to translate the node into translation set giving the added benefit of full control over the translated node (add/remove fields, change options, etc.) which also allows the title field of the node to then be translated if you need it (most do because that is the only way to do it right now) but when doing so the user will be shown the translated node in the set and so their submition will be linked to that translated node and not the original node. The wording of keeping a "single" webform comes from being able to use i18n sync functionality to sync the common fields between the nodes in the translation set. This syncing however does not move the results or prevent you from changing the form on a specific node of a translation set that you need to be different.

rv0’s picture

@dragonwize
There can be more to a node than just the title field. What about body field? Taxonomy fields? The webform enabled content types I'm using have over 20 fields (and I'm not talking about webform fields).

When you talk about content translation, that is what Entity Translation does: http://drupal.org/project/entity_translation
However we are not using entity translation.

What you are saying is contradictory to the text on the main sandbox page:

A) If you want to keep a single webform across all nodes in a translation set:
Use i18n_string integration to translate webform strings. This module expose webform properties, components and emails strings through the i18n module. All submissions results are related to the original node only.
(You have a "localization by string translation" fieldset in the form settings to enable this)

- i want to keep a single webform across all nodes in my translation set (4 languages, EN, PL, NL, FR)
- I am using i18n string translation

This is _EXACTLY_ my use case. Correct me if I'm wrong.

But if you are keeping a single webform across all nodes in a translation set, the webform tabs on the translated nodes will direct to a wrong, unused, webform. Which gets overridden anyway by the code in node_view.
The issue here is that those tabs need to be hidden on translations of nodes, and a new tab needs to be added that redirects to the source node webform, just as GDrupal says.

dragonwize’s picture

Unfortunately you are wrong but it is obvious it is because the description is badly worded.

When i say content translation, I am not talking about entity_translation module which allows you to translate fields (which the title field is not a "field" in the fieldable system so it is not translatable via entity_translation), I am talking about the core Content Translation module (translation.module) which allows you to create multiple nodes and keep them in a translation set (which at the current time is the best way to translate the title).

We, and most people, are using the same methods you are. However, this module does not use a technical "single webform" across the nodes in a translation set, it allows you "sync" the webform fields from one node in the set to the other nodes in the set which gives the appearance of a single webform because you only have to edit one to edit them all however they are still separate and so keep separate results etc. This gives great flexibility but comes at some cost the same as similar situations.

rv0’s picture

dragonwize: I am not using the Sync option.

My config is:

LOCALIZATION BY STRING TRANSLATION
x Expose webform component strings suitable for translation.
x Keep a single webform across a translation set.

If I am wrong, then how come whatever I'm doing is working just fine?

And btw, I know it's not using "a technical "single webform" across the translation" set.
I think I know exactly what it does ;)

rv0’s picture

Status: Needs work » Needs review
StatusFileSize
new3.2 KB

This is it

Seems to work just nice.
Removes the tabs from translations when using the single webform setup.
Adds a new tab "source webform" which links to the original.
(patch created at Coworks)

rv0’s picture

Ah just realized the following problem: "webform primary types" (like the "webform" content type webform provides) will redirect to webform/components after node creation.
When you add a translation, you'll end up with a page not found.
Imho, in this case, it's best to remove the redirect as you don't want to edit the webform after creating a translation of the content.

Patch will follow

rv0’s picture

Addressing #14:
Following patch also removes the webform submit function (which does nothing but redirect) on nodes defined in the hidden webform_node_types_primary variable, when using ['single_webform']:

(patch created at Coworks)

GDrupal’s picture

@rv0 :
I will act as a bridge here between @dragonwize and you.

@dragonwize:
The scenario when you need to translate nodes using content translation and i18n integration is expected. @rv0 is right about that, he is talking only about a usability issue with all the webform tab being unusable most of the time.

But and i'm talking to both right now.... I realize from your discussion that a new scenario emerges. What will happen perhaps if you have a translation set with 4 languages and 3 of them can work with i18n_integration as @rv0 is using it and the last node needs a completely different webform (cultural reasons i don't know), but you want to keep some properties synchronized between the source webform and the different one.

I'm thinking Ouch! I have not foresee that.... so very interesting stuff there. In a case like that, we need a more general option to let you choose wich node does not need the webform tab and which one does. Or perhaps showed it by default and add an option to "replace it /hide" it when the webform its empty.

I dont know for sure a lot to think.....

rv0’s picture

When ['single_webform'] is set, the translation's webform is always overridden in hook_node_view.
Everything in my patch only does stuff when ['single_webform'] is set.. So in any case it won't break or limit any of the current functionality, as far as I can see.

Either way, the way this works, replacing the webform on node_view, feels like a hack, but there's no better way I think, thats just to blame on the legacy architecture of webform.
Hope entity based webform solutions will be worth it when D8 comes, but for now, we have to use hacks like this, I guess..

OT: I've written integration with this module for webform_template ( http://drupal.org/project/webform_template ) and I'm wondering if I should commit it already. @GDrupal If you have time to review it...

GDrupal’s picture

@rv0: I will review this indeed!
I'm in the middle of a new module (media plugin) but i will make sometime and let you know ASAP.
Thank you for all this great work!

dragonwize’s picture

Well if you understand me then I will go back to my original point.

You have to have the webform tab on translated nodes so it would be a horrible user issue to redirect or remove that tab because it is needed to edit, see results, etc. that weform so it has to be there for the user to use. Which makes this patch "closed (won't fix)".

I won't change the status now because I feel like there is still something in our conversations that is missing but based on everything you have said so far that is my conclusion.

rv0’s picture

@dragonwize
From reading your comment, I have a feeling you still don't understand what the patch in #15 does exactly.

dragonwize’s picture

Maybe I do not. What it appears to be from the title of this issue, the text in the issue, and the code in #15, it is trying to redirect the user to the source webform config from the translated config. The problem with that is that, that should never be done. That would be horrible to not be able to get the to appropriate webform because you are always redirected to the source form when the user needs to be able to access that version of the form because while some fields may be synced sometimes they are not the same and can be changed.

rv0’s picture

Fields are not synced in this use case.
and even if they were, the form would not even show because single_webform is checked. (it only shows the form of the source node)

GDrupal’s picture

I have to agree with @rv0 on this... Here there is a resume of a long chat with dragonwize just to clarify this scenario:

You can also use the i18n_string integration with node translation by the single_webform feature.
What it does is: use the webform in the source node and displayed in all nodes in the translation set with the proper translation from i18n_string. if you have exactly the same components with the same options just in different language this is all you need.

This is the scenario where @rv0 needs to implement this feature. In this scenario we have a bunch of empty webfroms, since the one and only webform is configured only from the source node.

The only complication that I see on this, is the emergent scenario that I mention on http://drupal.org/node/1481594#comment-5736196

I hope that now we are all in the same page?

GDrupal’s picture

I'm in the process of reviewing http://drupal.org/node/1481594#comment-5736132 still not so sure about a couple of things so I will test it more deeply. In relation to my observations in http://drupal.org/node/1481594#comment-5736196 i have added a little changes so a new patch. I will continue analyzing the code to be sure we are no missing or breaking something.

rv0’s picture

Patch in #24 was giving me problems, don't really know why.
- it was showing the webform and results tabs
- webform_source was giving me page not found

cleared cache multiple times and watched the diff, but saw nothing that could have caused it.

In any case, I don't think it's a good idea to allow both "Single webform" and a specific webform within one translation set. It's confusing and hard to provide custom integration with it.

rv0’s picture

Status: Needs review » Needs work

After submission, you get redirected to a /done page.
However that path had been disabled in menu_alter.
Skipping that particular path:

function webform_localization_menu_alter(&$items) {
  foreach ($items as $path => $item) {
    if (strpos($path, 'node/%webform_menu/') === 0 && $path != 'node/%webform_menu/done') {
      $items[str_replace('node/%webform_menu/', 'node/%webform_localization_menu/', $path)] = $item;
      unset($items[$path]);
    }
  }
}
rv0’s picture

Any progress?

How about making this an official project btw? Any issue blockers?

GDrupal’s picture

@rv0: Sorry about this, but I was focus on a first commit for 2 other modules... I have to discuss some of this changes with the sponsor of the module for now is the only blocker. I will let you know ASAP. Are you in a hurry?

jweowu’s picture

FWIW, I'd be inclined to implement webform_menu_to_arg() to just make the local task tabs go to the correct URLs in the first place. I can't think of a reason why webform itself would ever implement this, so it's highly unlikely to ever conflict.

edit: Logged a webform feature request #2097277: Consider alterable webform_menu_to_arg() implementation

mareks’s picture

Version: » 7.x-4.x-dev
Status: Active » Needs work

I agree that having Webform related tabs (Webform and Results) on a translated node are kind of misleading in case of "Keep a single webform across a translation set.".

However, another problem is that, when I submit a translated node Webform then I get an Access denied message. Yes I know that the results are saved on a different (related) node but still... Confirmation message is would be very user friendly to have a Thank you message :)

I can tackle this by setting my form Redirection location to Custom URL or No redirect (reload current page) ... with maybe some template tricks.

jweowu’s picture

mareks: Surely that is (a) unrelated to this issue, and (b) well-covered by #2096583: After submitting translated node webform I get 403 Access denied (which you had already logged) ?

Frederic wbase’s picture

I' ve rerolled the patch from #15 witch works at my setup to use with version 4.x.
Whats the future of this issue?

jweowu’s picture

The future of this issue is (or should be) that #2097277: Consider alterable webform_menu_to_arg() implementation allows us to fix it properly. We won't need any redirects, because all the links will point to the correct URL in the first place.

I do plan to provide a patch for this, now that #2097277 has been committed.

joseph.olstad’s picture

Status: Needs work » Needs review

@jweowu I know it's been 11 months since the last update on this issue but any chance of a follow up?

future of this issue is .... allows us to.... fix it properly

Status: Needs review » Needs work
joseph.olstad’s picture

Status: Needs work » Closed (duplicate)
Parent issue: » #2097277: Consider alterable webform_menu_to_arg() implementation

this was fixed in the parent issue

jweowu’s picture

Hi Joseph. My apologies for not following up your previous message; I should have posted a patch for this before now. #2097277: Consider alterable webform_menu_to_arg() implementation is really a child of this issue, not the other way around.

Here is a re-roll (based on this upstream change to webform) of the custom patch I've been using since September 2013.

joseph.olstad’s picture

Hi Jweowu , thanks for the patch, I reviewed, it looks pretty good and passes tests however I'm wondering , do we need a check to see if the option for single webform?
ex:

if ($webform_localization_options['sync_components']) {
 ....
}

so maybe line 264 should be this:

    if ($nid = webform_localization_single_webform_nid($node) && $webform_localization_options['sync_components']) {

instead of:

    if ($nid = webform_localization_single_webform_nid($node)) {

?

what modes/options does /or should this functionality apply to?

jweowu’s picture

Be careful with your parentheses vs operator precedence. That variant would need to be if (($nid = webform_localization_single_webform_nid($node)) && $webform_localization_options['sync_components']) {

I assume you meant $webform_localization_options['single_webform'] rather than $webform_localization_options['sync_components'], though?

I haven't looked at this module for a long time, but I guess the answer is "probably"? I suspect it saves an unnecessary database query when the single_webform option isn't being used.

The test elsewhere seems to be explicitly ($webform_localization_options['single_webform'] > 0) rather than a simple boolean value, so I imagine that should be maintained for consistency at least.

Note also that webform_localization_node_view() was not making any such test. That function was the original source of the code that I've moved into webform_localization_single_webform_nid(). If we're adding in the additional test, we should probably put it inside webform_localization_single_webform_nid() (returning FALSE if it's not set) and therefore gain the benefit in the webform_localization_node_view() case as well; but we need to be certain that it is also correct in that case.

jweowu’s picture

A look at webform_localization_get_config() makes me dubious that the single_webform option is going to be present for all the non-tnid nodes in the translation set?

...yes, calling that function for a non-tnid node gives you data for the (unused) webform associated with that specific (non-tnid) node, rather than the 'single' webform data for the tnid for that translation set.

All of which makes me think the original code was correct to not be testing the option.

We could be checking the single_webform value of webform_localization_get_config($node->tnid), OTOH. I believe that's just another way of checking the exact same data, but you might still prefer to do it that way?

jweowu’s picture

Also notable is that webform_localization_preprocess_webform_confirmation() performs an almost-identical query, but with one difference in the WHERE clause, which is that one of the queries requires that wl.single_webform <> 0, and the other does not.

However I believe they are intended to be doing the same thing, in which case they could both be abstracted into a call to webform_localization_single_webform_nid().

That difference between the two queries is mitigated by the opening block of webform_localization_preprocess_webform_confirmation(), which returns immediately when empty($vars['node']->tnid), which means that adding the query constraint that wl.single_webform <> 0 would be a no-op for that function.

n.b. This is the case because a separate constraint requires that wl.single_webform is equal to $node->tnid

joseph.olstad’s picture

Looking back at the patch again,

    if ($nid = webform_localization_single_webform_nid($node)) {

was probably meant to be

    if ($nid == webform_localization_single_webform_nid($node)) {

haven't yet had time to look closely at this but at a glance I'd say it should probably be using the == operator as we're not assigning anything we would be comparing the nid in this if statement

jweowu’s picture

No, absolutely not.

if ($nid = webform_localization_single_webform_nid($node)) {...} is assigning a value to $nid, and then testing it in a boolean context.

(because the value returned by the assignment operator is the value which was assigned.)

It is equivalent to:

$nid = webform_localization_single_webform_nid($node);
if ($nid) {...}
joseph.olstad’s picture

ah ok, thanks.

joseph.olstad’s picture

StatusFileSize
new2.67 KB
new1.66 KB

Hi jweowu , referring to comment #39 yes I meant

$webform_localization_options['single_webform']

good observation.

Based on your comments I have come up with a new patch, I added in the check for 'single_webform' in the webform_localization_single_webform_nid function as you suggested.

Please review this patch and interdiff and let me know if you think this makes sense. (and if possible test it for me? :) )

Thanks a bunch for your patch and assistance.

joseph.olstad’s picture

joseph.olstad’s picture

joseph.olstad’s picture

Status: Needs review » Needs work

need to re trigger the testbot

joseph.olstad’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 45: webform_localization_webform_menu_to_arg-1481594-45.patch, failed testing.

The last submitted patch, 45: webform_localization_webform_menu_to_arg-1481594-45.patch, failed testing.

The last submitted patch, 45: webform_localization_webform_menu_to_arg-1481594-45.patch, failed testing.

The last submitted patch, 45: webform_localization_webform_menu_to_arg-1481594-45.patch, failed testing.

joseph.olstad’s picture

StatusFileSize
new2.74 KB
joseph.olstad’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 54: webform_localization_webform_menu_to_arg-1481594-53.patch, failed testing.

The last submitted patch, 54: webform_localization_webform_menu_to_arg-1481594-53.patch, failed testing.

The last submitted patch, 54: webform_localization_webform_menu_to_arg-1481594-53.patch, failed testing.

The last submitted patch, 54: webform_localization_webform_menu_to_arg-1481594-53.patch, failed testing.

joseph.olstad’s picture

Status: Needs work » Needs review

reverting back to patch 37.

We'll have to try testing patch 37 manually to see if it is compatible with the other webform_localization modes ('single_webform' should work according to simpletest , would be nice to add some tests to simpletest for the other types, probably better to make more simpletest tests to do this for us.)

jweowu’s picture

For clarity, I actually said (in comment 40) that testing the value of single_webform for the current node was the wrong thing to do (but that we could potentially do that for the translation source node for the current node's translation set -- much like I've done in _webform_localization_mollom_form_alter() in my patch you committed for #2137195: Mollom support for the 'single webform' localization option, in fact).

I do think this code could be cleaned up some more, so I'll try to revisit this later on. I think #37 is most likely usable, though (I've been running a near-identical patch in a production system for the past two years).

joseph.olstad’s picture

how about we commit patch #37 as is, if there's any issues with it we'll deal with it as it comes. As you say, you've been using a close version of it in production for 2 years.

  • joseph.olstad committed 2e8f0ae on 7.x-4.x
    Issue #1481594 by rv0, jweowu, GDrupal, Frederic wbase: Redirect webform...

  • joseph.olstad committed cfbe096 on 7.x-4.x authored by jweowu
    Issue #1481594 by rv0, jweowu, GDrupal, Frederic wbase: Redirect webform...
joseph.olstad’s picture

Status: Needs review » Fixed

committed, thanks jweowu

Status: Fixed » Closed (fixed)

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