maikschneider / bw_icons

TYPO3 extensions that provides an icon picker for TCA and RTE.
GNU General Public License v2.0
1 stars 2 forks source link

TCA form not saving into database #60

Open pjope opened 3 weeks ago

pjope commented 3 weeks ago

Hello,

I added the plugin as described, and when I enable it for pages, everything works fine.

Now I tried to add the field only to a specific page doktype, without adding it to the others.

The icon picker is showing up, and I can pick an icon. It is displayed in the field after selection.

However, if I save the record now, nothing is saved to the database.

If I manually edit the record in the database and enter the icon string into the tx_bwicons_icon field, the icon picker field is correctly filled with the correct icon in TYPO3.

(function() {
  $customIconClass = 'apps-pagetree-page-shortcut';

  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
      'pages',
      'doktype',
      [
          'label' => 'LLL:EXT:portal/Resources/Private/Language/locallang_tca.xlf:PageTypes.socialMedia',
          'value' => 1000,
          'icon' => $customIconClass,
          'group' => 'special',
      ],
  );
  $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][1000] = $customIconClass;
  $GLOBALS['TCA']['pages']['types'][1000] = [
      'showitem' => '
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                    doktype,
                    --palette--;;title,
                    'tx_bwicons_icon'
                    --palette--;;external,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
                    --palette--;;abstract,
                    --palette--;;editorial,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,
                    --palette--;;layout,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,
                    --palette--;;miscellaneous,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.resources,
                    --palette--;;media,
                    --palette--;;config,
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
                    --palette--;;language,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.access,
                    --palette--;;visibility,
                    --palette--;;access,
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
                    categories,
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
                    rowDescription,
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
            ',
      'columnsOverrides' => [
          'tx_bwicons_icon' => [
              'label' => 'Icon',
              'config' => [
                  'type' => 'input',
                  'renderType' => 'iconSelection',
              ],
          ],
      ],
  ];
})();

image

Greetings Phil

maikschneider commented 3 weeks ago

Hey Phil. I'm not sure why the selected icon is not saved correctly. Your config for the doktype 1000 looks a bit strange though:

 --palette--;;title,
                    'tx_bwicons_icon'
                    --palette--;;external,

The quotes around tx_bwicons_icon should not be necessary. The columnsOverrides are not needed as well (the configuration is already done for this field).

Just an idea: If you want to restrict the icon field to only a specific doktype, TCEFORM would be much easier:

# disable the icon field for pages
TCEFORM.pages.tx_bwicons_icon.disabled = 1
# enable the icon field for a specific page type
TCEFORM.pages.tx_bwicons_icon.types.1000.disabled = 0

Try again and let me know. Cheers!