Skip to content

Inline Fluid pipe breaks required content argument when additional args are passed (getContentArgumentName) #1304

@Kanti

Description

@Kanti

Description
In Fluid inline syntax using the pipe operator, ViewHelpers that rely on getContentArgumentName() behave inconsistently when the content argument is required.

Works (no exception)

{content.content -> my:wrap()}

Fails (throws exception)

{content.content -> my:wrap(xxx: '')}

Error

Required argument "content" was not supplied. (error code 1237823699)

Minimal example ViewHelper (uses renderChildren())

<?php
declare(strict_types=1);

namespace Vendor\Extension\ViewHelpers;

use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

final class WrapViewHelper extends AbstractViewHelper
{
    public function initializeArguments(): void
    {
        // required "content argument" as defined by getContentArgumentName()
        $this->registerArgument('content', 'string', 'Content from pipe', true);
        $this->registerArgument('xxx', 'string', 'Unused optional argument', false, '');
    }

    public function getContentArgumentName(): string
    {
        return 'content';
    }

    public function render(): string
    {
        return '[' . (string)$this->renderChildren() . ']';
    }
}

Scope
Affects any ViewHelper where:

  • the content argument (via getContentArgumentName()) is required
  • used inline with the pipe operator
  • any additional named argument is passed

Expected
Piped value should still satisfy the required content argument even when other args are provided.

Actual
Adding any named argument causes the piped value to not be mapped to the required content argument, triggering the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions