Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Tokens von Feldern, deren Feldname auf "-suffix" o.ä. enden, werden in E-Mails nicht ersetzt! #363

Closed
bildschirmartist opened this issue Sep 19, 2024 · 12 comments
Labels

Comments

@bildschirmartist
Copy link
Contributor

Moin zusammen,
wir haben ein Problem, das seit kurzem auftritt:
Es wurde ein Formular eingerichtet, dass über notification_center eine E-Mail generiert und verschickt. Hier sind auch einige Formularfelder enthalten, deren Feldname auf -suffix endet. Beispiel:

  • customer-id
  • product-id
  • error-message

Diese werden in den E-Mails aktuell aber nicht ersetzt, stattdessen sieht die generierte E-Mail so aus:
image

Als Workaround haben wir die Felder nun wie folgt umbenannt:

  • customerId
  • productId
  • errorMessage

Damit funktioniert es für uns temporär wieder.

Beste Grüße

@bildschirmartist
Copy link
Contributor Author

Kurze Ergänzung: Scheinbar betrifft es sämtliche Formularfelder, die ein - im Namen beinhalten

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 19, 2024

Isn't this a known limitation of simple tokens? Or do such tokens work outside of the NC?

@bildschirmartist
Copy link
Contributor Author

Isn't this a known limitation of simple tokens? Or do such tokens work outside of the NC?

Hi @fritzmg,
thanks for your quick response.
Maybe this is a known limitation of simple tokens but it worked at least until v.2.0.9 of NC.
If it is a limitation, then this should be mentioned in the documentation when it comes to the ##form_*## Simple Token description, because it is a valid form field name.

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 19, 2024

It does look like simple tokens with - are supported in general:

// outputs "Hello World!"
$this->simpleTokenParser->parse('##foo-bar##', ['foo-bar' => 'Hello World!'])

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 19, 2024

The change was introduced in 8d4e519

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 19, 2024

@Toflar I don't think it is necessary to silently remove the characters from the variable name. It just means you cannot use it for {if …} etc. There also won't be any errors if you try.

@Toflar
Copy link
Member

Toflar commented Sep 19, 2024

You cannot have dashes - in token names. It's forbidden. That's why the NC normalizes them to _.

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 19, 2024

@Toflar but you can. ##foo-bar## will output the content of the token. The only thing that won't work is

{if foo-bar …}

etc.

And that applies to everywhere in Contao, not just the NC.

@Toflar
Copy link
Member

Toflar commented Sep 19, 2024

Yes, and we want unified tokens otherwise people don't understand why it works in ## but not in the {if statement. In Contao 5, using it in the {if statement with a - will cause an error. Hence, they are normalized. Just use _ instead of - and continue your day - no need to discuss this further.

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 19, 2024

In Contao 5, using it in the {if statement with a - will cause an error.

No, I just tried, it does not cause an error.

@fritzmg
Copy link
Collaborator

fritzmg commented Jan 15, 2025

See #390

@Toflar
Copy link
Member

Toflar commented Jan 16, 2025

I have decided to automatically generate both, normalized and original token names in version 2.2.5. This means that ##form_product-id## should now work again but if you want to use it in comparisons, you'll have to use {if form_product_id == 42}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants