TYPO3 Extension-Builder output select-value of IRRE in Fluid

479 Views Asked by At

I clicked me a little extension in the Extension Builder together. It is a general object (wall) with IRRE-elements (windows in the wall - 1:n). This IRRE-element has an select-box (window-color) with different values. I added the values in the Override-folder, so they don't become overwritten when I add another field in the Extension Builder.

In my template I loop through all n elements and try to output each one in a partial. But now in the browser there are only the IDs displayed ant not the values.

Here is my TCA-Override:

$GLOBALS['TCA']['MY_EXTENSIO']['columns']['color']['config']['items'] = [
['Green', 0],
['Red', 1],
['Blue', 2],
['Gray with orange dots', 3],
];

The way I render it in the partial

{window.color} // window  is the passed variable of the loop

In the backend everything works just fine. Even if I save data, reload... There is always the name of the color (e.g. "Blue") selected. But in the frontend the output is simply "2" - the ID of the color. I did not anything else: rather I changed the controller nor I worked multilangue...

Does anybody of you have clue for me? I'am googling since hours without any result.

1

There are 1 best solutions below

3
On

TCA-Override:

$GLOBALS['TCA']['MY_EXTENSIO']['columns']['color']['config']['items'] = [
['Green', '#060'],
['Red', '#F00'],
['Blue', '#00F'], // for better practice I suggest classes like: ['Blue', 'blue-color-code']
['Gray with orange dots', '#999'],
];

Change field type in ext_tables.sql -> donot forget to update DB from install tool

CREATE TABLE tx_hous_domain_model_window (
   color varchar(255) DEFAULT '' NOT NULL
);

Just have a look your model should be look like:

class Window extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
   protected $color = '';

   public function getColor() {
        return $this->color;
   }
   public function setColor($color) {
        $this->color = $color;
   }
}

in your view:

{window.color} <!-- either you'll get '#00F' for blue or 'blue-color-code' class as per your TCA config -->

Donot forget to clear install tool cache