From 62ab667ddb5e371dede0048ca4dfb049ef73b72f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 22 May 2025 16:23:01 +0200 Subject: [PATCH] Attempt to fix multi value handling with placeholders This partly reverts and augments 131fd50 The validator call is needed to transform the given value into to proper format (eg. an array for multivalues or an array of array for multi-page values). This has to be done after applying place holders. This might also fix #729 It might also break other usecase so it needs more real world testing. Overall the bureaucracy handling is a mess, because bureaucracy is a mess. Until splitbrain/dokuwiki-plugin-bureaucracy#303 has been addressed, there is no good way to fix this. --- helper/field.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/helper/field.php b/helper/field.php index af8b8f9f..408d6e53 100644 --- a/helper/field.php +++ b/helper/field.php @@ -49,8 +49,8 @@ protected function setVal($value) { if (!$this->column) { $value = ''; - //don't validate placeholders here - } elseif ($this->replace($value) == $value) { + } else { + $value = $this->replace($value); $validator = new ValueValidator(); $this->error = !$validator->validateValue($this->column, $value); if ($this->error) { @@ -158,6 +158,16 @@ public function replacementMultiValueCallback($matches) */ protected function createValue() { + /* + $preparedValue = $this->opt['value'] ?? ''; + if($this->column->isMulti()) { + // multi-value fields are treated as comma-separated lists + $preparedValue = explode(',', $preparedValue); + $preparedValue = array_map('trim', $preparedValue); + $preparedValue = array_filter($preparedValue); + } + */ + // input value or appropriately initialized empty value $preparedValue = $this->opt['value'] ?? ($this->column->isMulti() ? [] : '');