Skip to content

Commit

Permalink
[BUGFIX] Create unique marker names when adding new fields
Browse files Browse the repository at this point in the history
This fixes a regression when field properties were extended with types and when the array should be changed to a field object.

Related: #787
  • Loading branch information
einpraegsam committed Jul 8, 2022
1 parent 2a8a884 commit a31ca4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Classes/Domain/Model/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ class Field extends AbstractEntity
protected int $l10nParent = 0;

/**
* @var ?Page
* @var Page
* This property can hold Page|int|null (depending on the context). "@var" must set to Page for property mapping.
*/
protected ?Page $page = null;
protected $page = null;

/**
* @return string
Expand Down
14 changes: 8 additions & 6 deletions Classes/Hook/CreateMarker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtilityCore;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\Exception;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;

/**
* Class CreateMarker to autofill field marker with value from title e.g. {firstname}
Expand Down Expand Up @@ -238,13 +237,16 @@ protected function addNewFields(): void
*/
protected function getFieldObjectFromProperties(array $properties, string $uid = '0'): Field
{
$dataMapper = GeneralUtility::makeInstance(DataMapper::class);
if (isset($properties['uid']) === false) {
$properties['uid'] = null;
$field = GeneralUtility::makeInstance(Field::class);
$properties['sender_email'] = (bool)$properties['sender_email'];
$properties['sender_name'] = (bool)$properties['sender_name'];
$properties['mandatory'] = (bool)$properties['mandatory'];
$properties['validation'] = (int)$properties['validation'];
foreach ($properties as $key => $value) {
$field->_setProperty(GeneralUtility::underscoredToLowerCamelCase($key), $value);
}
$field = $dataMapper->map(Field::class, [$properties])[0];
if (!empty($properties['sys_language_uid'])) {
$field->_setProperty('_languageUid', (int)$properties['sys_language_uid']);
$field->_setProperty('_languageUid', $properties['sys_language_uid']);
}
$field->setDescription((string)($properties['uid'] ?? '') > 0 ? (string)$properties['uid'] : $uid);
return $field;
Expand Down

0 comments on commit a31ca4e

Please sign in to comment.