Configuration of EXT:extender - fields not visible in frontend
We're in the process of updating a Typo3 page that had several fields added to tt_address. After updating EXT:extender to version 10.1.1. there is no frontend output of these fields anymore. The fields are visible in the backend and can be edited.
We've used this manual: https://docs.typo3.org/p/friendsoftypo3/tt-address/main/en-us/Development/ExtendTtAddress/Index.html#development-extend-ttaddress
Current Behavior no frontend output of the additional fields
Expected behavior/output The content of our fields should show up in the frontend.
Environment
- TYPO3 version(s): 12.4.18
- tt_address version: 9.0.1
- Is your TYPO3 installation set up with Composer (Composer Mode): no
- OS: Windows 10
Possible Solution It looks like there were breaking changes in EXT:extender version 10. It would be nice, if the documentation of tt_address could be updated.
Additional context Here is the code of our Address.php
<?php
namespace GeorgRinger\AddressField\Extending\Domain\Model;
class Address extends \FriendsOfTYPO3\TtAddress\Domain\Model\Address
{
/** @var string */
protected $adhinstitution = '';
/**
* @return string
*/
public function getAdhInstitution()
{
return $this->adhinstitution;
}
/**
* @param string $adhinstitution
*/
public function setAdhInstitution($adhinstitution)
{
$this->adhinstitution = $adhinstitution;
}
/** @var string */
protected $adhdepartment = '';
/**
* @return string
*/
public function getAdhDepartment()
{
return $this->adhdepartment;
}
/**
* @param string $adhdepartment
*/
public function setAdhDepartment($adhdepartment)
{
$this->adhdepartment = $adhdepartment;
}
/** @var string */
protected $adhstatus = '';
/**
* @return string
*/
public function getAdhStatus()
{
return $this->adhstatus;
}
/**
* @param string $adhstatus
*/
public function setAdhStatus($adhstatus)
{
$this->adhstatus = $adhstatus;
}
}
ext_localconf.php
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['tt_address']['extender'][\FriendsOfTYPO3\TtAddress\Domain\Model\Address::class]['address_field'] = 'my_extension/Domain/Model/Address';
We have the same problem with Typo3 12.4.20 (composer installation) / extender 10.1.1 / tt_address 9.0.1
I could also reproduce the problem not being able to extend the table with own/custom fields using TYPO3 12.4.22 (legacy, NOT composer based installation) and tt_address 9.0.1.
The custom fields became available using the "old" approach extending $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'] within the "ext_localconf.php" and the "Configuration/Extbase/Persistence/Classes.php" files like so:
file "ext_localconf.php"
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\FriendsOfTYPO3\TtAddress\Domain\Model\Address::class] = [
'className' => \<VENDORNAME>\<EXTENSIONNAMESPACE>\Domain\Model\Address::class
];
file "Configuration/Extbase/Persistence/Classes.php"
return [
// ...
\<VENDORNAME>\<EXTENSIONNAMESPACE>\Domain\Model\Event::class => [
'tableName' => 'tx_calendarize_domain_model_event',
],
];
Btw: I would like to know, why this "old" way is not the preferred way and why the "extender" extension is needed. Is it, because fo more complex models it's not working?
it is because xclassing works only 1 time, the extender makes it possible to extend a class multiple times. if you just need something in your project, feel free to do it this way!
In your Sitepackage you have to add the File"Services.yaml" in the Folder "Configuration", there you add the Following Code:
services:
VENDORNAME\EXTENSIONNAMESPACE\Extending\Domain\Model\Address:
tags:
-
name: 'extender.extends'
class: FriendsOfTYPO3\TtAddress\Domain\Model\Address
This replaces the Code in the ext_locaconf.php
https://docs.typo3.org/p/evoweb/extender/main/en-us/Breaking/Index.html
@taunusweb: For me extending models is now working again with "extender". Tested using TYPO3 12 (legacy and composer based installations) and TYPO3 13 (only composer based installation tested).
Hope for @Dani-mam it works as well.
Thanx :)
Can confirm - it works. Thank you @taunusweb!
So could someone pls close this issue? I had been removed from contributors list recently, so I cannot do that anymore.