Bug #28982
Form Viewhelper can't handle nested translation viewhelper
| Status: | Closed | Start date: | 2011-08-15 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Bastian Waidelich | % Done: | 0% |
|
| Category: | Fluid: ViewHelpers | |||
| Target version: | - | |||
| Complexity: | ||||
| Votes: | 0 |
Description
For example this should be possible (tosearch is a valid locallang label containing "suchen" in German):
<f:form.submit name="submit" id="submit" value="<f:translate key="tosearch" />" />
But it results in the following rendered html:
<f:form.submit name="submit" id="submit" value="suchen" />
History
Updated by Claus Due almost 2 years ago
Hi Matthias,
The output looks like it is exactly what is expected - "suchen" being the translated "tosearch" key?
You should probably do this instead, though:
<f:form.submit name="submit" id="submit" value="{f:translate(key: 'tosearch')}" />
Updated by Bastian Waidelich almost 2 years ago
- Status changed from New to Needs Feedback
Updated by Matthias Krappitz almost 2 years ago
I would not say that the above output is as expected, since the f:form.submit Tag itself stays unparsed. But the inline syntax you provided works! So it is generally not possible to have viewhelpers in viewhelpers in Fluid like I wrote it?
And there is another problem in this example, even with inline syntax:
<f:form.textfield name="q" value="{f:translate(key: 'searchterm')}" additionalAttributes="{onfocus : 'if (this.value == \'{f:translate(key: 'searchterm')}\') this.value = \'\';', onblur : 'if (this.value == \'\') this.value = \'{f:translate(key: 'searchterm')}\';'}" id="q" class="searchInput" />
This leads to:
Uncaught TYPO3 Exception
#1237900529: The argument "additionalAttributes" was registered with type "array", but is of type "string" in view helper "Tx_Fluid_ViewHelpers_Form_TextfieldViewHelper"
Updated by Claus Due almost 2 years ago
Missed the "f:" part in your output, sorry.
Using you should always use inline syntax when defining arguments.
Regarding your example I would definitely move such a function to an external script, which loads the default value of the submit button and uses it to check against on your onfocus. You will almost always have severe problems if you mix Javascript (or any other ECMA) into Fluid arguments since the escaping interceptors react to the same syntax.
This said there could still be an issue in Fluid which prevents escaping single quotes in individual values in a Fluid argument of type "array" - I'm not familiar enough with the Fluid internals to say if that is the case, but using an external Javascript with a function should solve the issue quickly and painlessly.
Sebastian and Bastian would be the guys to ask about this.
Using Fluid variables in a Javascript is very nice - I agree totally on that - which is why I wrote these (and around 100 others...) you might be able to use:
http://fedext.net/viewhelpers/header-data/script/ and http://fedext.net/viewhelpers/header-data/style/
(you can use Fluid variables and ViewHelpers inside fed:script and fed:style)
Updated by Bastian Waidelich almost 2 years ago
- Status changed from Needs Feedback to Closed
- Assignee set to Bastian Waidelich
- Priority changed from Must have to Should have
Hi.
As I see it, this is just a matter of propper nesting of Fluid tags (which frankly said, is not very easy to get, but consequent). See http://forge.typo3.org/projects/typo3v4-mvc/wiki/FAQ#Can-ViewHelpers-be-nested for more details and feel free to comment here if you have more questions.
Updated by Anja Leichsenring 6 months ago
- Project changed from Extbase MVC Framework to Fluid
- Category changed from 963 to Fluid: ViewHelpers