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
This commit is contained in:
nathan 2024-12-11 10:39:36 -07:00
parent aaefb6ce68
commit 7933936c72
3 changed files with 8 additions and 2 deletions

View File

@ -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)));

View File

@ -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)))
{

View File

@ -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;