mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-12-26 07:46:09 +01:00
[FEATURE] Add value picker for skill set selection in content element
This commit is contained in:
parent
41beb0310a
commit
f37a57e46e
4 changed files with 69 additions and 1 deletions
55
Classes/FormDataProvider/ValuePickerItemDataProvider.php
Normal file
55
Classes/FormDataProvider/ValuePickerItemDataProvider.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace SkillDisplay\SkilldisplayContent\FormDataProvider;
|
||||
|
||||
use SkillDisplay\PHPToolKit\Api\SkillSet;
|
||||
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
|
||||
|
||||
/**
|
||||
* Inject available skill sets a valuepicker form
|
||||
*/
|
||||
class ValuePickerItemDataProvider implements FormDataProviderInterface
|
||||
{
|
||||
private SkillSet $skillSetApi;
|
||||
|
||||
public function __construct(SkillSet $skillSetApi)
|
||||
{
|
||||
$this->skillSetApi = $skillSetApi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sys_domains into $result data array
|
||||
*
|
||||
* @param array $result Initialized result array
|
||||
* @return array Result filled with more data
|
||||
*/
|
||||
public function addData(array $result): array
|
||||
{
|
||||
if ($result['tableName'] === 'tt_content' && isset($result['processedTca']['columns']['skilldisplay_skillset'])) {
|
||||
$skillSets = $this->skillSetApi->getAll();
|
||||
foreach ($skillSets as $skillSet) {
|
||||
$result['processedTca']['columns']['skilldisplay_skillset']['config']['valuePicker']['items'][] =
|
||||
[
|
||||
$skillSet->getName(),
|
||||
$skillSet->getId(),
|
||||
];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,11 @@
|
|||
'type' => 'input',
|
||||
'eval' => 'required',
|
||||
'size' => 10,
|
||||
'valuePicker' => [
|
||||
'mode' => 'append',
|
||||
// filled by ValuePickerItemDataProvider
|
||||
'items' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
'skilldisplay_campaign' => [
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.1 || ^8.2",
|
||||
"skilldisplay/phptoolkit": "^2.0.1",
|
||||
"skilldisplay/phptoolkit": "^2.1",
|
||||
"typo3/cms-backend": "^11.5 || ^12.4",
|
||||
"typo3/cms-frontend": "^11.5 || ^12.4"
|
||||
},
|
||||
|
|
|
@ -26,6 +26,14 @@
|
|||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$extKey] =
|
||||
\SkillDisplay\SkilldisplayContent\Backend\Preview::class;
|
||||
|
||||
// Inject skillsets into valuepicker form
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord']
|
||||
[\SkillDisplay\SkilldisplayContent\FormDataProvider\ValuePickerItemDataProvider::class] = [
|
||||
'depends' => [
|
||||
\TYPO3\CMS\Backend\Form\FormDataProvider\TcaInputPlaceholders::class,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$caches = [
|
||||
'sdcontent',
|
||||
|
|
Loading…
Reference in a new issue