Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed May 15, 2017
1 parent 8225fe4 commit 43968c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Classes/Form/Definition/AbstractFormDefinitionComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ protected function handlePropertyMagicMethod($property, $type, array $arguments)
}

/**
* @param array $data
* @param array $data
* @param string $property
* @param string $name
*/
protected static function forceNameForProperty(&$data, $property)
protected static function forceNameForProperty(&$data, $property, $name = 'name')
{
if (isset($data[$property])
&& is_array($data[$property])
) {
foreach ($data[$property] as $key => $entry) {
$data[$property][$key]['name'] = $key;
$data[$property][$key][$name] = $key;
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion Classes/Form/Definition/Field/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Romm\Formz\Form\Definition\Field\Validation;

use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor;
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessorInterface;
use Romm\ConfigurationObject\Traits\ConfigurationObject\ArrayConversionTrait;
use Romm\Formz\Exceptions\DuplicateEntryException;
use Romm\Formz\Exceptions\EntryNotFoundException;
Expand All @@ -24,7 +26,7 @@
use Romm\Formz\Form\Definition\Field\Field;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class Validator extends AbstractFormDefinitionComponent implements ActivationUsageInterface
class Validator extends AbstractFormDefinitionComponent implements ActivationUsageInterface, DataPreProcessorInterface
{
use ArrayConversionTrait;

Expand Down Expand Up @@ -257,4 +259,20 @@ public function getParentField()

return $field;
}

/**
* @param DataPreProcessor $processor
*/
public static function dataPreProcessor(DataPreProcessor $processor)
{
$data = $processor->getData();

/*
* Forcing the identifiers of the messages: they are the keys of the
* array entries.
*/
self::forceNameForProperty($data, 'messages', 'identifier');

$processor->setData($data);
}
}

0 comments on commit 43968c2

Please sign in to comment.