Closed craftzneko closed 7 months ago
@mikhail-vl or @asimonok any ideas on the above i am using the documented example to clear the values but it appears they are not cleared. I have this code in element value changed which should clear certain elements when switching
/**
* Find Search element
*/
const searchElement = context.panel.elements.find((element) => element.id === "Search");
/**
* Define mapping of Search options to element IDs that should not be cleared
*/
const elementsToKeep = {
"Single": ["FetchLimit", "Search", "AssetName"],
"Filter": ["FetchLimit", "Search", "DeviceModel", "OSBuild"],
"Software": ["FetchLimit", "Search", "Software"],
"Custom": ["FetchLimit", "Search"]
};
/**
* Get array of element IDs that should not be cleared based on the current Search option
*/
const elementIdsToKeep = elementsToKeep[searchElement.value] || [];
/**
* Update Panel Options
*/
context.panel.onOptionsChange({
...context.panel.options,
elements: context.panel.elements.map((element) => {
return elementIdsToKeep.includes(element.id) ? element : { ...element, value: "" };
}),
});
So looking at the object mutli select "value" is being cleared but its query lookup so how do i clear that?
I have an option that should hide other form elements but if the form elements have values in it doesnt hide it the first time
Example, i select software from this dropdown
I then switch over to "Filter" search and the form element changes to "Model" from "Software" but the value stays defined in the selection
My code to hide the box looks like this and is in the form show if value is true
If i select another "search option" at the top of my form it then correctly clears it and continue to work even if i select "search option software" again