mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 17:24:46 +02:00
Fix issue processwire/processwire-issues#1010 add support for dependencies to InputfieldPageListSelectMultiple and InputfieldPageAutocomplete
This commit is contained in:
@@ -331,7 +331,24 @@ var InputfieldPageAutocomplete = {
|
||||
$ol.append($li);
|
||||
|
||||
InputfieldPageAutocomplete.rebuildInput($ol);
|
||||
InputfieldPageAutocomplete.triggerChange($ol);
|
||||
},
|
||||
|
||||
/**
|
||||
* Trigger change event
|
||||
*
|
||||
* @param $item Any element within the autocomplete Inputfield
|
||||
*
|
||||
*/
|
||||
triggerChange: function($item) {
|
||||
var $input;
|
||||
if($item.hasClass('InputfieldPageAutocompleteData')) {
|
||||
$input = $item;
|
||||
} else {
|
||||
if(!$item.hasClass('Inputfield')) $item = $item.closest('.Inputfield');
|
||||
$input = $item.find('.InputfieldPageAutocompleteData')
|
||||
}
|
||||
$input.trigger('change');
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -399,6 +416,7 @@ $(document).ready(function() {
|
||||
var id = $li.children(".itemValue").text();
|
||||
$li.remove();
|
||||
InputfieldPageAutocomplete.rebuildInput($ol);
|
||||
InputfieldPageAutocomplete.triggerChange($ol);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -1099,6 +1099,8 @@ function InputfieldDependencies($target) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var $inputfield = $field.closest('.Inputfield');
|
||||
|
||||
// value of the dependency field we are checking (if not already populated above)
|
||||
if (value === null) {
|
||||
if($field.attr('type') == 'checkbox') {
|
||||
@@ -1123,9 +1125,12 @@ function InputfieldDependencies($target) {
|
||||
if (typeof value == 'object') {
|
||||
// object, convert to array
|
||||
values = jQuery.makeArray(value);
|
||||
} else if (typeof value == 'array') {
|
||||
} else if(typeof value == 'array') {
|
||||
// array, already
|
||||
values = value;
|
||||
} else if(typeof value == "string" && $inputfield.hasClass('InputfieldPage') && value.indexOf(',') > -1 && value.match(/^[,0-9]+$/)) {
|
||||
// CSV string of page IDs
|
||||
values = value.split(',');
|
||||
} else {
|
||||
// string: single value array
|
||||
values[0] = value;
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user