swiener
swiener

Reputation: 41

TYPO3: Default setting in TCA overwritten when settable via Flexforms in Extbase Extension

I added the possibility to set a detailPid in my Extension via flexforms:

<ROOT>
  <type>array</type>
  <el>
    <settings.detailPid>
      <TCEforms>
        <label>
    LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:flexforms.overview.detailPid
        </label>
        <config>
          <type>group</type>
          <internal_type>db</internal_type>
          <allowed>pages</allowed>
          <size>1</size>
          <maxitems>1</maxitems>
          <show_thumbs>1</show_thumbs>
          <wizards>
            <suggest>
              <type>suggest</type>
            </suggest>
          </wizards>
        </config>
      </TCEforms>
    </settings.detailPid>
  </el>
</ROOT>

I want to set the default detailPid via TS in my setup.ts:

plugin.tx_events_eventdetail {
    settings {
        listPid = {$plugin.tx_events_eventdetail.settings.listPid}
        detailPid = {$plugin.tx_events_eventdetail.settings.detailPid}
    }
}

My problem is, that if I don't configure a detailPid in my plugin, the default value from my TS is not used. The settings.detailPid in my Controller or in the FLUID-Template is empty. Is there a way to just fix that?

I already looked around and found out, that the news-extension has the same behavior.

Thanks for any help and suggestions!

Upvotes: 0

Views: 884

Answers (2)

Paul Beck
Paul Beck

Reputation: 2685

You can rename your flexforms detailPid path to something like settings.flexform.detailPid then in your controller you may merge the settings from TS with those from the Flexform so that only non empty values will take affect.

ArrayUtility::arrayMergeRecursiveOverrule($this->settings, $this-settings['flexform'])

https://api.typo3.org/typo3cms/current/html/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_utility_1_1_array_utility.html#af4008bc539411e9114ed53b1b007735b

Upvotes: 1

Georg Ringer
Georg Ringer

Reputation: 7939

At least the extensions tt_address and news have a configuration which allow a fallback to TS if flexform is empty. If you need that, you can copy the code and use that in your extension.

There is no configuration available in the core for that.

Upvotes: 1

Related Questions