Skip to content

Commit 43b5957

Browse files
committed
[BUGFIX] Create unique marker names when adding new fields
This fixes a regression when field properties were extended with types and when the array should be changed to a field object. Related: #787
1 parent 2a8a884 commit 43b5957

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Classes/Domain/Model/Field.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ class Field extends AbstractEntity
141141
protected int $l10nParent = 0;
142142

143143
/**
144-
* @var ?Page
144+
* @var Page
145+
* This property can hold Page|int|null (depending on the context). "@var" must set to Page for property mapping.
145146
*/
146-
protected ?Page $page = null;
147+
protected $page = null;
147148

148149
/**
149150
* @return string

Classes/Hook/CreateMarker.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtilityCore;
1212
use TYPO3\CMS\Core\Utility\GeneralUtility;
1313
use TYPO3\CMS\Extbase\Object\Exception;
14-
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
1514

1615
/**
1716
* Class CreateMarker to autofill field marker with value from title e.g. {firstname}
@@ -238,13 +237,20 @@ protected function addNewFields(): void
238237
*/
239238
protected function getFieldObjectFromProperties(array $properties, string $uid = '0'): Field
240239
{
241-
$dataMapper = GeneralUtility::makeInstance(DataMapper::class);
242-
if (isset($properties['uid']) === false) {
243-
$properties['uid'] = null;
240+
$field = GeneralUtility::makeInstance(Field::class);
241+
$properties['contentelement'] = (int)($properties['contentelement'] ?? 0);
242+
$properties['validation'] = (int)($properties['validation'] ?? 0);
243+
$properties['multiselect'] = (bool)($properties['multiselect'] ?? false);
244+
$properties['sender_name'] = (bool)($properties['sender_name'] ?? false);
245+
$properties['sender_email'] = (bool)($properties['sender_email'] ?? false);
246+
$properties['mandatory'] = (bool)($properties['mandatory'] ?? false);
247+
$properties['sorting'] = (int)($properties['sorting'] ?? 0);
248+
$properties['l10n_parent'] = (int)($properties['l10n_parent'] ?? 0);
249+
foreach ($properties as $key => $value) {
250+
$field->_setProperty(GeneralUtility::underscoredToLowerCamelCase($key), $value);
244251
}
245-
$field = $dataMapper->map(Field::class, [$properties])[0];
246252
if (!empty($properties['sys_language_uid'])) {
247-
$field->_setProperty('_languageUid', (int)$properties['sys_language_uid']);
253+
$field->_setProperty('_languageUid', $properties['sys_language_uid']);
248254
}
249255
$field->setDescription((string)($properties['uid'] ?? '') > 0 ? (string)$properties['uid'] : $uid);
250256
return $field;

0 commit comments

Comments
 (0)