Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Classes/Form/AbstractFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function build(): array
'exclude' => intval($this->getExclude()),
'config' => $configuration
];
if (($description = $this->getDescription()) && $description !== null) {
$fieldStructureArray['description'] = $this->getDescription();
}
if (($displayCondition = $this->getDisplayCondition())) {
$fieldStructureArray['displayCond'] = $displayCondition;
}
Expand Down
2 changes: 2 additions & 0 deletions Classes/ViewHelpers/Field/AbstractFieldViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function initializeArguments(): void
'the name of the field.'
);
$this->registerArgument('default', 'string', 'Default value for this attribute');
$this->registerArgument('description', 'string', 'Field description', false);
$this->registerArgument(
'native',
'boolean',
Expand Down Expand Up @@ -161,6 +162,7 @@ protected static function getPreparedComponent(
static::getExtensionNameFromRenderingContextOrArguments($renderingContext, $arguments)
);
$component->setDefault($arguments['default']);
$component->setDescription($arguments['description']);
$component->setRequired($arguments['required']);
$component->setExclude($arguments['exclude']);
$component->setEnabled($arguments['enabled']);
Expand Down
9 changes: 9 additions & 0 deletions Tests/Unit/Form/Field/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ public function canChainSetterForEnableRichText()
$this->assertTrue($instance->getEnableRichText());
}

public function testBuildDescription()
{
$subject = Text::create(['name' => 'test', 'description' => 'desc']);
$config = $subject->build();
$this->assertArrayHasKey('label', $config);
$this->assertArrayHasKey('description', $config);
$this->assertEquals('desc', $config['description']);
}

public function testBuildConfigurationWithRteResolving(): void
{
$subject = $this->getMockBuilder(Text::class)
Expand Down
14 changes: 14 additions & 0 deletions Tests/Unit/Form/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ public function testBuildCreatesExpectedTcaArray(): void
);
}

public function testBuildSupportsDescription(): void
{
$settings = [
'type' => 'input',
'name' => 'test',
'description' => 'desc',
];
$subject = Field::create($settings);
$output = $subject->build();

self::assertArrayHasKey('description', $output);
self::assertEquals('desc', $output['description']);
}

public function testCanGetAndSetType(): void
{
$this->assertGetterAndSetterWorks('type', 'sometype', null, true);
Expand Down
17 changes: 17 additions & 0 deletions Tests/Unit/ViewHelpers/Field/Inline/FalViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ public function createsExpectedComponent()
$this->assertInstanceOf(Fal::class, $component);
}

/**
* @test
*/
public function supportsDescription()
{
$arguments = [
'name' => 'test',
'description' => 'testdesc'
];
$instance = $this->buildViewHelperInstance($arguments, []);
$component = $instance->getComponent(
$this->renderingContext,
$this->buildViewHelperArguments($instance, $arguments)
);
$this->assertEquals($arguments['description'], $component->getDescription());
}

/**
* @test
*/
Expand Down
14 changes: 14 additions & 0 deletions Tests/Unit/ViewHelpers/Field/TextViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ class TextViewHelperTest extends AbstractFieldViewHelperTestCase
'name' => 'test',
];

/**
* @test
*/
public function supportsDescription()
{
$arguments = ['name' => 'test', 'description' => 'testdesc'];
$instance = $this->buildViewHelperInstance($arguments);
$component = $instance->getComponent(
$this->getInaccessiblePropertyValue($instance, 'renderingContext'),
$this->getInaccessiblePropertyValue($instance, 'arguments')
);
$this->assertSame($arguments['description'], $component->getDescription());
}

/**
* @test
*/
Expand Down
14 changes: 14 additions & 0 deletions Tests/Unit/ViewHelpers/FieldViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,18 @@ class FieldViewHelperTest extends AbstractFieldViewHelperTestCase
'name' => 'test',
'type' => 'input',
];

/**
* @test
*/
public function supportsDescription()
{
$arguments = ['name' => 'test', 'type' => 'input', 'description' => 'testdesc'];
$instance = $this->buildViewHelperInstance($arguments);
$component = $instance->getComponent(
$this->getInaccessiblePropertyValue($instance, 'renderingContext'),
$this->getInaccessiblePropertyValue($instance, 'arguments')
);
$this->assertSame($arguments['description'], $component->getDescription());
}
}