From 7933936c72fbd89d28e82142465e82bb5a030de6 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 11 Dec 2024 10:39:36 -0700 Subject: [PATCH] Fix multiple validation issues - Sub-templates were not getting processed - Buttons without ID could clear / overwrite all sibling widgets - Vfs validate checked widget type, some are now web components --- api/src/Etemplate/Widget/Button.php | 6 ++++++ api/src/Etemplate/Widget/Template.php | 2 +- api/src/Etemplate/Widget/Vfs.php | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/Etemplate/Widget/Button.php b/api/src/Etemplate/Widget/Button.php index 67341ecfd7..d3c375b635 100644 --- a/api/src/Etemplate/Widget/Button.php +++ b/api/src/Etemplate/Widget/Button.php @@ -46,6 +46,12 @@ class Button extends Etemplate\Widget */ public function validate($cname, array $expand, array $content, &$validated=array()) { + // Can't "validate" a button without an ID. + // It won't have anywhere to go in the $content, and may overwrite its siblings + if(!$this->id) + { + return; + } $form_name = self::form_name($cname, $this->id, $expand); //error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name))); diff --git a/api/src/Etemplate/Widget/Template.php b/api/src/Etemplate/Widget/Template.php index b84f3d4b2f..eeb42e1a1a 100644 --- a/api/src/Etemplate/Widget/Template.php +++ b/api/src/Etemplate/Widget/Template.php @@ -252,7 +252,7 @@ class Template extends Etemplate\Widget $expand_name = self::expand_name($this->original_name, '','','','',self::$request->content); } //error_log("$this running $method_name() cname: {$this->id} -> expand_name: $expand_name"); - if($expand_name && $expand_name != $this->id) + if($expand_name && ($expand_name != $this->id || $cname !== $old_cname)) { if (($row_template = self::instance($expand_name))) { diff --git a/api/src/Etemplate/Widget/Vfs.php b/api/src/Etemplate/Widget/Vfs.php index 239473d21a..96d8fe8360 100644 --- a/api/src/Etemplate/Widget/Vfs.php +++ b/api/src/Etemplate/Widget/Vfs.php @@ -351,7 +351,7 @@ class Vfs extends File public function validate($cname, array $expand, array $content, &$validated=array()) { // do not validate, as it would overwrite preserved values with null! - if (in_array($this->type, array('vfs-size', 'vfs-uid', 'vfs-gid', 'vfs', 'vfs-mime')) || + if(in_array($this->type, array('vfs-size', 'et2-vfs-uid', 'et2-vfs-gid', 'vfs', 'et2-vfs-mime')) || $this->is_readonly($cname, $form_name = self::form_name($cname, $this->id, $expand))) { return;