appearance

appearance
Type:array
Scope:Display

Properties that only apply to how the field is displayed in the backend.

appearance:prefix
Type:userFunction
Scope:Display

Provides a string that is displayed in front of the input field.

Assign a user function. It receives two arguments:

  • The first argument is the parameters array containing the site object, the language id, the current table and the current row.
  • The second argument is the reference object TcaSlug.

The user function should return the string which is then used for display purposes.

Example

../../../../_images/Slug1.png
'columns' => [
    'slug_1' => [
        'exclude' => 1,
        'label' => 'slug_1',
        'description' => 'field description',
        'config' => [
            'type' => 'slug',
            'generatorOptions' => [
                'fields' => [
                    'input_1',
                    'input_2',
                ],
                'fieldSeparator' => '/',
                'prefixParentPageSlug' => true,
                'replacements' => [
                    '/' => '',
                ],
            ],
            'appearance' => [
                'prefix' => 'TYPO3\\CMS\\Styleguide\\UserFunctions\\FormEngine\\SlugPrefix->getPrefix',
            ],
            'fallbackCharacter' => '-',
            'eval' => 'uniqueInSite',
            'default' => '',
        ],
    ],
]

The user function can be implemented like this:

<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Styleguide\UserFunctions\FormEngine;

/**
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

/**
 * A user function to compare two fields
 */
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSlug;

class SlugPrefix
{
    public function getPrefix(array $parameters, TcaSlug $reference): string
    {
        return 'custom slug prefix';
    }
}