16trait PrefixableDataProviderTrait
28 protected function splitPrefixFilterValues(
string $prefix, array $fields): array
33 foreach ($fields as $nameWithPrefix => $value)
35 $name = $this->removePrefix($prefix, $nameWithPrefix);
37 if ($name === $nameWithPrefix)
39 $otherFields[$name] = $value;
43 $prefixFields[$name] = $value;
47 return [$prefixFields, $otherFields];
50 protected function removePrefix(
string $prefix,
string $fieldId): string
52 return str_replace($prefix,
'', $fieldId);
55 protected function addPrefix(
string $prefix,
string $fieldId): string
57 return $prefix . $fieldId;
68 protected function appendPrefixName(
string $prefixNameTemplate,
string $fieldName): string
70 return str_replace(
'#NAME#', $fieldName, $prefixNameTemplate);
84 protected function prepareFieldsByPrefix(
string $prefix, array $fields, ?
string $prefixNameTemplate =
null, ?array $iconParams =
null, ?
string $sectionId =
null): array
88 foreach ($fields as $id => $field)
90 if ($field instanceof Field)
92 $newId = $this->addPrefix($prefix, $id);
93 $field->setID($newId);
95 $name = $field->getName();
98 if (isset($prefixNameTemplate))
100 $name = $this->appendPrefixName($prefixNameTemplate, $name);
103 $field->setName($name);
106 if (isset($iconParams))
108 $field->setIconParams($iconParams);
111 if (isset($sectionId))
113 $field->setSectionId($sectionId);
116 $result[$newId] = $field;