[TYPO3-english] Re: Typo3 foreign_table: How to specify a specific column to a select drop down menu?

christian ewigfrost christian-kulozik at gmx.net
Thu Oct 26 13:53:50 CEST 2017


Quote: Mikel wrote on Wed, 25 October 2017 16:38
----------------------------------------------------
> OK. Yes, that is possible. Like I said --> itemsProcFunc.
> 
> Go into your tca, to the select field.
> 'renderType' => 'selectSingle',
> 'foreign_table' => 'tx_cvfoobar_domain_model_kunde',
> 'itemsProcFunc' => ‚Foobar\CvFoobar\Tca\SelectProcFunc->prepareItems',
> 
> class SelectProcFunc
> {
> 
>    public function prepareItems($param) {
>       $newItems = [];
>       foreach ($param['items'] as $item) {
>          $newItem = [
>             0 => 'Enter your label',
>             1 => 'enter_your_value'
>          ];
>          $newItems[] = $newItem;
>       }
>       $param['items'] = $newItems;
>       return $param;
>    }
> 
> }
> 
> Just as a quick example. That inserts only static values and labels.
> To get more information from related Kunde record, you need to make an instance of the repository and load the record by uid. 
> You need to allow string inserts, if kundeuid is just a string.
> 
> BUT: This is not a very safe solution. You write the values into the database. What happens, if a user changes the kundeuid in one of the records? The relation is broken, as the value has been written into the database.
> Also, for db queries, you need to compare strings. You also need to evaluate, that kundeuid is unique (if needed).
> 
> What is your target? Do you want to group records by that attribute „kundeuid"? If so, you should better add another model „Kundengruppe" with m:n relations to Appliance and Kunde. This also would make db queries more easy, as you can build queries from both sides and get your Appliance by Kundengruppe and also your Kunden by Kundengruppe.
> 
> Mikel
----------------------------------------------------

Actually assigning the auto generated uid property was the right thing to do, there was just a missunderstanding between my boss and me. My aim is to generate .conf files for the Icinga2 monitoring system and using the tables generated by the extension. A user should be able to create Hosts, Appliances and also create Services that are directly assigned to a Host (and also specified in the .conf files of Icinga, but that has nothing to do with TYPO3, so i won't go into detail). Then an admin should be able to check the entries the user made in the TYPO3 backend and then run a php script that creates those .conf files from the tables that the extension generated. I'm not quite sure yet how to do this yet, but as this has nothing to do with TYPO3 i'll ask at Stackoverflow.^^

But there is one thing i don't know yet: I just can't find the tables in phpmyadmin. I don't know why.


More information about the TYPO3-english mailing list