Files

38 lines
1.2 KiB
Python

class DynamicComboGenerator:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"multiline_entries": ("STRING", {"multiline": True, "default": "Option_1\nOption_2\nOption_3"}),
# Start with a placeholder array; the JS file will dynamically swap these options out
"selected_value": (["Option_1"], {}),
}
}
# Outputting wildcard "*" allows the Set/Get system to bypass rigid connection validation
RETURN_TYPES = ("*",)
RETURN_NAMES = ("VALUE",)
FUNCTION = "process_combo"
CATEGORY = "CustomRouting"
def process_combo(self, multiline_entries, selected_value):
# Fallback security: return whatever value is currently written/selected
return (str(selected_value),)
@classmethod
def VALIDATE_INPUTS(cls, **kwargs):
# Overriding this native method forces ComfyUI's backend executor to bypass
# the rule checking if 'selected_value' exists in the original static ["Option_1"] array.
return True
NODE_CLASS_MAPPINGS = {
"DynamicComboGenerator": DynamicComboGenerator
}
NODE_DISPLAY_NAME_MAPPINGS = {
"DynamicComboGenerator": "Dynamic Text-to-Combo"
}