Hi, I'm using some form for sending data to another form with "Custom form settings > form method" where I can add my destination address (and passing fields data by GET).

The point is that I've realized that I can't translate the destination URL in case I have diferent language versions of the destination form (let's say of the destination page). Is there any way to send the get action to different URLs based on language ??

Comments

JordiTR created an issue. See original summary.

jorditr’s picture

Issue summary: View changes
jrockowitz’s picture

Ouch!!! This is not easy to fix via the UI. It should very easy to fix via custom code. I even think you can embed the current page's langcode as token in your custom URL

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new675 bytes

So I determined that token replacement is not working for the form #action. The attached patch fixes this issue.

jrockowitz’s picture

StatusFileSize
new2.27 KB
new4.34 KB

The attached webform provides a reasonable work-around where you can create a hidden form action element and populate the #action using a token.

The attached patch is required to make this possible. The attached patch requires a lot of testing because it is extracting the default values from every form element and passing to the Webform Submission's data. I think this is a really important improvement that just needs work, test coverage, and even a change record.

  '#method': get
  '#action': '[webform_submission:values:action]'
  q:
    '#type': textfield
    '#title': 'Search Google'
  action:
    '#type': value
    '#title': 'Form Action'
    '#value': 'https://www.google.es/search'

  • 20dfdf6 committed on 3081154-form-method
    Issue #3081154 by jrockowitz: Form method multilingual
    

  • 68e458f committed on 3081154-form-method
    Issue #3081154 by jrockowitz: Form method multilingual. Fix typo.
    
jorditr’s picture

Hei Jacob, thanks a lot! Let me check your code.

  • 6641682 committed on 3081154-form-method
    Issue #3081154 by jrockowitz: Form method multilingual. Refactor...
jrockowitz’s picture

StatusFileSize
new11.81 KB

Attached patch is probably the best solution but it still needs some test coverage.

jrockowitz’s picture

StatusFileSize
new9.03 KB

Arg!!! The previous was not sync'd with the 8.x-5.x branch.

  • 6fe776d committed on 3081154-form-method
    Issue #3081154 by jrockowitz: Form method multilingual
    
jrockowitz’s picture

StatusFileSize
new21.7 KB

  • jrockowitz authored 830c0f6 on 8.x-5.x
    Issue #3081154 by jrockowitz: Form method multilingual
    
jrockowitz’s picture

Status: Needs review » Fixed

Since the patch has test coverage, I committed it. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

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