|
@@ -10,6 +10,33 @@ class KeyValue extends Field
|
|
|
{
|
|
|
const DEFAULT_FLAG_NAME = '_def_';
|
|
|
|
|
|
+ protected $keyLabel;
|
|
|
+ protected $valueLabel;
|
|
|
+
|
|
|
+ public function setKeyLabel(?string $label)
|
|
|
+ {
|
|
|
+ $this->keyLabel = $label;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setValueLabel(?string $label)
|
|
|
+ {
|
|
|
+ $this->keyLabel = $label;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getKeyLabel()
|
|
|
+ {
|
|
|
+ return $this->keyLabel ?: __('Key');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getValueLabel()
|
|
|
+ {
|
|
|
+ return $this->valueLabel ?: __('Value');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -45,8 +72,8 @@ class KeyValue extends Field
|
|
|
|
|
|
$rules["{$this->column}.keys.*"] = 'distinct';
|
|
|
$rules["{$this->column}.values.*"] = $fieldRules;
|
|
|
- $attributes["{$this->column}.keys.*"] = __('Key');
|
|
|
- $attributes["{$this->column}.values.*"] = __('Value');
|
|
|
+ $attributes["{$this->column}.keys.*"] = $this->getKeyLabel();
|
|
|
+ $attributes["{$this->column}.values.*"] = $this->getValueLabel();
|
|
|
|
|
|
$input = $this->prepareValidatorInput($input);
|
|
|
|
|
@@ -76,7 +103,9 @@ class KeyValue extends Field
|
|
|
$value = $this->value();
|
|
|
|
|
|
$this->addVariables([
|
|
|
- 'count' => $value ? count($value) : 0,
|
|
|
+ 'count' => $value ? count($value) : 0,
|
|
|
+ 'keyLabel' => $this->getKeyLabel(),
|
|
|
+ 'valueLabel' => $this->getValueLabel(),
|
|
|
]);
|
|
|
|
|
|
return parent::render();
|