Paw-Issues icon indicating copy to clipboard operation
Paw-Issues copied to clipboard

Set InputField choices dynamic

Open langeland opened this issue 6 years ago • 1 comments

As fare as I can see it is not possible to set the ´choices´ option on a InputField with the type Select. Is this possible, or is it something that is in a pipeline ?

I've added a little mockup of what i'am trying to do.

var SelectValue = function() {
	this.evaluate = function() {
		var posibleChoices = [];

		this.posibleValues.forEach(function(posibleValue) {
			if (posibleValue[2]) {
				posibleChoices.push(posibleValue[0]);
			}
		});

		// This is not working
		this.selectedValue.choices = posibleChoices;
		return this.selectedValue;
	}


	this.title = function(context) {
		return this.fieldName;
	}

	this.text = function(context) {
		return this.selectedValue;
	}
}

SelectValue.inputs = [
	InputField("selectedValue", "Selected value", "Select", {"choices": {"k1": "v1"}, persisted: true}),
	InputField("posibleValues", "Posible values2", "KeyValueList", {"keyName":"Display name", "valueName":"Value"}),
	InputField("fieldName", "Name", "String", {persisted: true, defaultValue: "", placeholder: "Type a name"}),
];

SelectValue.identifier = "info.langeland.SelectValue";
SelectValue.title = "Select Value";
SelectValue.help = "https://luckymarmot.com/paw/doc/";
registerDynamicValueClass(SelectValue)

Thanks /

langeland avatar May 03 '18 07:05 langeland

Any updates on this? 🤞 Either way, +1.

Urbanproof avatar Jul 23 '21 09:07 Urbanproof