1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00

Update Inputfield class so that dependencies can be supported on many ajax-loaded Inputfields before they are… ajax-loaded.

This commit is contained in:
Ryan Cramer
2024-05-31 14:30:33 -04:00
parent 34bca47a07
commit 7c85b089dd
3 changed files with 22 additions and 2 deletions

View File

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

View File

@@ -1182,7 +1182,22 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
$url .= "renderInputfieldAjax=$inputfieldID";
$url = $sanitizer->entities($url);
$out = "<div class='renderInputfieldAjax'><input type='hidden' value='$url' /></div>";
$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 = "<input type='hidden' id='$inputfieldID' value='$val' />";
}
}
$out =
"<div class='renderInputfieldAjax'>" .
"<input type='hidden' value='$url' />" .
$valueInput .
"</div>";
if($inputfield instanceof InputfieldWrapper) {
// load assets they will need

View File

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