0

我用于 TYPO3 TCA 后端国家选择器、类型选择和 EXT:static_info_tables // static_info_tables_de

它在后端完美运行。我这里有一个国家——选择:

'land' => array(
    'exclude' => 1,
    'label' => 'Land',
    'displayCond' => 'EXT:static_info_tables_de:LOADED:true',
    'config' => array(
        'type' => 'select',
        'renderType' => 'selectSingle',
        'items' => array(
            array('', 0)
        ),
        'foreign_table' => 'static_countries',
        'allowNonIdValues' => TRUE,
        'foreign_table_where' => 'ORDER BY static_countries.cn_short_de',
        'itemsProcFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\FormDataProvider\\TcaSelectItemsProcessor->translateCountriesSelector',
        //'itemsProcFunc_config' => array(
        //    'indexField' => 'cn_short_de',
        //),
        'size' => 1,
        'minitems' => 0,
        'maxitems' => 1,
        'default' => '54', // Default Germany value="54"
        'eval' => 'required'
    )
),

FE Debug 输出为 =land => '54' (2 chars) 但是,我不知道如何更改 Country-Name 中的 ID?

这是模型 - 代码:

/**
 * Land
 *
 * @var string
 *
 */
protected $land = '';

/**
 * Returns the land
 *
 * @return string $land
 */
public function getLand() {
    return $this->land;
}

/**
 * Sets the land
 *
 * @param string $land
 * @return void
 */

public function setLand($land) {
    $this->land = $land;
}

我为 FE Select-Form 找到了这个示例,但我需要正确的“Country”-Name 而不是 FORM-Selector。 https://docs.typo3.org/typo3cms/extensions/static_info_tables/ExtbaseDomainModel/UsingTheModel/AddingACountrySelectFieldToAForm/Index.html

我想,我不需要“字符串”..我需要这个:

@param \SJBR\StaticInfoTables\Domain\Repository\CountryRepository $land

感谢帮助!塞巴斯蒂安

4

1 回答 1

3

您最可能想要做的是在您的领域模型中建立适当的关系。您已经在 TCA 中设置了关系,因此请调整您的模型:

/**
 * @var \SJBR\StaticInfoTables\Domain\Model\Country
 */
protected $land = '';

/**
 * @return \SJBR\StaticInfoTables\Domain\Model\Country $land
 */
public function getLand() {
    return $this->land;
}

/**
 * @param \SJBR\StaticInfoTables\Domain\Model\Country $land
 * @return void
 */  
public function setLand(\SJBR\StaticInfoTables\Domain\Model\Country $land) {
    $this->land = $land;
}

静态信息表扩展已经告诉 extbase 如何将数据库表映射到\SJBR\StaticInfoTables\Domain\Model\Country模型。因此,在此更改之后,您应该能够获取国家/地区的名称。

$model->getLand()->getOfficialNameLocal();

您可以检查模型以了解您现在可以使用哪些吸气剂。

于 2016-02-24T08:43:43.333 回答