From 89be912b2828f73aa728ab2d1347de9d26aada17 Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Thu, 7 Dec 2017 11:19:23 +0100 Subject: [PATCH 1/2] fix: struct_field in bureaucracy form now supports a default value Before that we cannot use bureaucracy default values for struct_field ("=default value" syntax). Now it's possible. --- helper/field.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helper/field.php b/helper/field.php index 210e2bc4..82b8ba6e 100644 --- a/helper/field.php +++ b/helper/field.php @@ -22,7 +22,7 @@ class helper_plugin_struct_field extends helper_plugin_bureaucracy_field { * @param array $args */ public function initialize($args) { - parent::initialize($args); + $this->init($args); // find the column try { @@ -30,6 +30,8 @@ public function initialize($args) { } catch(StructException $e) { msg(hsc($e->getMessage()), -1); } + + $this->standardArgs($args); } /** From 131fd5072854c061dbfcaed3090dde745b3249c1 Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Tue, 9 Jan 2018 10:32:38 +0100 Subject: [PATCH 2/2] fix: to proper handle placeholders in default values for struct fields, we must validate them only on submit --- helper/field.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper/field.php b/helper/field.php index 82b8ba6e..bfc9c183 100644 --- a/helper/field.php +++ b/helper/field.php @@ -43,7 +43,8 @@ public function initialize($args) { protected function setVal($value) { if(!$this->column) { $value = ''; - } else { + //don't validate placeholders here + } elseif($this->replace($value) == $value) { $validator = new ValueValidator(); $this->error = !$validator->validateValue($this->column, $value); if($this->error) {