From 7c85b089dd8d3694abde8a365d9dfa351e385f75 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 31 May 2024 14:30:33 -0400 Subject: [PATCH] =?UTF-8?q?Update=20Inputfield=20class=20so=20that=20depen?= =?UTF-8?q?dencies=20can=20be=20supported=20on=20many=20ajax-loaded=20Inpu?= =?UTF-8?q?tfields=20before=20they=20are=E2=80=A6=20ajax-loaded.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wire/core/Inputfield.php | 6 +++++- wire/core/InputfieldWrapper.php | 17 ++++++++++++++++- .../InputfieldPageAutocomplete.module | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/wire/core/Inputfield.php b/wire/core/Inputfield.php index 7e2c4d2a..7b4bfe0a 100644 --- a/wire/core/Inputfield.php +++ b/wire/core/Inputfield.php @@ -1467,7 +1467,11 @@ abstract class Inputfield extends WireData implements Module { * */ public function renderReady(Inputfield $parent = null, $renderValueMode = false) { - $result = $this->wire()->modules->loadModuleFileAssets($this) > 0; + if($this->className() === 'InputfieldWrapper') { + $result = false; + } else { + $result = $this->wire()->modules->loadModuleFileAssets($this) > 0; + } if($this->wire()->hooks->isMethodHooked($this, 'renderReadyHook')) { $this->renderReadyHook($parent, $renderValueMode); } diff --git a/wire/core/InputfieldWrapper.php b/wire/core/InputfieldWrapper.php index 907b1c70..bfe3e312 100644 --- a/wire/core/InputfieldWrapper.php +++ b/wire/core/InputfieldWrapper.php @@ -1182,7 +1182,22 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre $url .= "renderInputfieldAjax=$inputfieldID"; $url = $sanitizer->entities($url); - $out = "
"; + $valueInput = ''; + $val = $inputfield->val(); + if(!is_array($val) && !is_object($val)) { + $val = (string) $val; + if(strlen("$val") <= 1024) { + // keep value in hidden input so dependences can refer to it + $val = $sanitizer->entities("$val"); + $valueInput = ""; + } + } + + $out = + "
" . + "" . + $valueInput . + "
"; if($inputfield instanceof InputfieldWrapper) { // load assets they will need diff --git a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module index 04950cb9..636ecfff 100644 --- a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module +++ b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module @@ -182,6 +182,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra $class = 'ui-autocomplete-input ' . ($this->useList ? 'has_list' : 'no_list'); if($this->useAndWords) $class .= " and_words"; if($this->allowAnyValue) $class .= " allow_any"; + $class = trim($sanitizer->entities("$class " . $this->attr('class'))); $disableChars = $this->disableChars; if($disableChars) {