0

I have written some ViewHelpers that work totally fine, but only in the Main-Section... For better understanding:

<f:section name="Configuration">
  <flux:field.select name="first" label="first" items="{0: '10', 1: '40'}"/>
  <flux:field.select name="second" label="second" items="{myViewHelpers:load()}"/>
</f:section>
<f:section name="Preview">
</f:section>
<f:section name="Main">
  {myViewHelpers:load()}
</f:section>

{myViewHelpers:load()} returns a string, with for example

{0: '10', 1: '40'}

In the Main-Section this perfectly works, but if I use the same ViewHelper in the Configuration-section, it just doesn't load the backend any more... I only get a blank field in Typo3, where normally the element arises.

I'd be grateful for any suggestions!

andreas
  • 16,357
  • 12
  • 72
  • 76
jockel
  • 3
  • 4

1 Answers1

0

Your ViewHelper returns a string that is in return interpreted by fluid as an array (curly braces). So fluid prints out nothing. Are you sure you don't need to pass that array to another ViewHelper like flux:field.select?

If you need to generate a usable array from your ViewHelper you should use

$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
$templateVariableContainer->add($arguments['myNewVariable'], $array);

Then you can access your variable like you normally would:

{myNewVariable.0}
sven
  • 609
  • 5
  • 14
  • I'm not sure if this would solve the problem, because I also had an option, to give it back as an Array, which also didn't work. I'm not sure if this would solve the problem, because something I haven't figured out yet, destroyed my ViewHelpers entirely. Even the working ones end up in an error. Anyway, thanks a lot for your Answer. I'm closing this question, because I'm not able to test the solutions... – jockel Jul 03 '16 at 13:49