0

Try to format that code in twig format:

<textarea class="form-control" name="email_review_subject_<?php echo $language['language_id']; ?>" ><?php echo isset(${'email_review_subject_' . $language['language_id']}) ? ${'email_review_subject_' . $language['language_id']} : ''; ?></textarea> 

So i tried with that format:

<textarea class="form-control" name="email_review_subject_{{ language['language_id'] }}" >{{ isset({'email_review_subject_' . language.language_id}) ? {'email_review_subject_' . language.language_id} : '' }}</textarea> 

Error:

Uncaught exception 'Twig_Error_Syntax' with message 'A hash key must be followed by a colon (:). Unexpected token "punctuation" of value "." ("punctuation" expected with value ":")

0

2 Answers 2

3

There is no such thing as isset in twig. You also need to access the special variable _context if you want use dynamic variables in twig

Some possible solutions,

<textarea class="form-control" name="email_review_subject_{{ language['language_id'] }}" >{{ attribute(_context, 'email_review_subject_'~language.language_id)|default('') }}</textarea> <textarea class="form-control" name="email_review_subject_{{ language['language_id'] }}" >{{ attribute(_context, 'email_review_subject_'~language.language_id) is defined ? attribute(_context, 'email_review_subject_'~language.language_id) : '' }}</textarea> 

fiddle

Sign up to request clarification or add additional context in comments.

Comments

3

I am pretty sure you can't use . to concatenate strings in Twig. Try ~, and look here: How to concatenate strings in twig

2 Comments

Have you replaced both concatenations in your code? If so, this error is unlikely because it specifically tells you that you have a period (.). If that fails, it might be a problem with using dynamic variable names. Try the attribute function: twig.symfony.com/doc/2.x/functions/attribute.html
I think the problem is here "(${"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.