Skip to content

Commit a31ca4e

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 a31ca4e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-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: 8 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,16 @@ 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['sender_email'] = (bool)$properties['sender_email'];
242+
$properties['sender_name'] = (bool)$properties['sender_name'];
243+
$properties['mandatory'] = (bool)$properties['mandatory'];
244+
$properties['validation'] = (int)$properties['validation'];
245+
foreach ($properties as $key => $value) {
246+
$field->_setProperty(GeneralUtility::underscoredToLowerCamelCase($key), $value);
244247
}
245-
$field = $dataMapper->map(Field::class, [$properties])[0];
246248
if (!empty($properties['sys_language_uid'])) {
247-
$field->_setProperty('_languageUid', (int)$properties['sys_language_uid']);
249+
$field->_setProperty('_languageUid', $properties['sys_language_uid']);
248250
}
249251
$field->setDescription((string)($properties['uid'] ?? '') > 0 ? (string)$properties['uid'] : $uid);
250252
return $field;

0 commit comments

Comments
 (0)