Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

merge with feat/allow-template-vars-for-search-fields

Forhad Hosain588082f9c1a6
diff --cc packages/app/src/builder-ui/ui/form/createFormField.ts
index 2e95e383,efccf440..656a9ea9
--- a/packages/app/src/builder-ui/ui/form/createFormField.ts
+++ b/packages/app/src/builder-ui/ui/form/createFormField.ts
@@@ -89,8 -87,42 +91,43 @@@ export default function createFormField
}
isDropdown = true;
- hasTemplateVarToggle =
- String(attributes?.['data-template-vars'] || '').toLowerCase() === 'true';
++ hasTemplateVarToggle = isTemplateVarsEnabled(attributes?.['data-template-vars']);
+
+ break;
+
+ case 'select-multiple':
+ case 'SELECT-MULTIPLE':
+ /**
+ * Native HTML multi-select field
+ * Supports multiple selections and search functionality
+ * Value should be an array of selected values
+ * createMultiSelectBox returns a container div with a nested select element
+ */
+ const multiSelectContainer = createMultiSelectBox(
+ entry.options,
+ Array.isArray(value) ? value : [],
+ entry?.dropdownHeight,
+ );
+
+ /**
+ * Get the actual select element from the container
+ * The container has a _selectElement property that references the select
+ */
+ const actualSelect = (multiSelectContainer as any)._selectElement as HTMLSelectElement;
+
+ if (entry.readonly && actualSelect) {
+ actualSelect.setAttribute('disabled', 'disabled');
+ }
+
+ /**
+ * Set formElement to the container, but store a reference to the select
+ * This allows the form system to work with the container while
+ * still being able to access the select for value retrieval
+ */
+ formElement = multiSelectContainer;
+ (formElement as any)._selectElement = actualSelect;
+
+ isDropdown = true;
break;
case 'checkbox':
@@@ -432,46 -462,34 +469,58 @@@
formElement.classList.add(`smt-input-${entry.type}`);
formElement.className += ` text-gray-900 border border-gray-200 sm:text-md ${fieldClasses}`;
+ if (templateVarInput) {
+ // Don't add Metro UI classes, use clean Tailwind styling instead
+ templateVarInput.className += ` text-gray-900 text-sm border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent ${fieldClasses}`;
+ }
+
if (entry?.type?.toLowerCase() !== 'key-value' && entry?.type?.toLowerCase() !== 'table') {
- formElement.setAttribute('id', entry.name);
- if (entry.name) formElement.setAttribute('name', entry.name);
+ // For non-select-multiple fields, apply id/name/attributes directly
+ if (entry?.type?.toLowerCase() !== 'select-multiple') {
+ formElement.setAttribute('id', entry.name);
+ if (entry.name) formElement.setAttribute('name', entry.name);
- // We configure attributes for 'key-value' type fields separately in the '_createKvInputField()' function in the file 'src/frontend/ui/form/keyValueField.ts'.
- for (let attr in attributes) {
- if (attr === 'data-vault-exclusive' && [true, 'true'].includes(attributes[attr])) {
- formElement.setAttribute('disabled', 'disabled');
- }
+ // We configure attributes for 'key-value' type fields separately in the '_createKvInputField()' function in the file 'src/frontend/ui/form/keyValueField.ts'.
+ for (let attr in attributes) {
+ if (attr === 'data-vault-exclusive' && [true, 'true'].includes(attributes[attr])) {
+ formElement.setAttribute('disabled', 'disabled');
+ }
- if (templateVarInput && attr === 'data-template-vars') {
- continue;
+ formElement.setAttribute(attr, attributes[attr]);
}
- formElement.setAttribute(attr, attributes[attr]);
+ // Automatically set autocomplete="off" for fields that support variable insertion
+ // data-template-vars can be "true" or an object like '{"enabled": true, "singleOnly": true}'
+ const hasTemplateVars = isTemplateVarsEnabled(attributes['data-template-vars']);
+
+ if (
+ (hasTemplateVars ||
+ attributes['data-agent-vars'] === 'true' ||
+ attributes['data-trigger-vars'] === 'true') &&
+ !attributes['autocomplete']
+ ) {
+ formElement.setAttribute('autocomplete', 'off');
+ }
}
+
+ if (templateVarInput) {
+ // Selectively copy attributes, excluding Metro UI and style-related attributes
+ const excludedAttrs = ['data-role', 'data-template-vars', 'disabled', 'readonly'];
+
+ for (let attr in attributes) {
+ // Skip Metro UI and excluded attributes
+ if (excludedAttrs.includes(attr)) {
+ continue;
+ }
+
+ // Don't set disabled even for vault-exclusive
+ if (attr === 'data-vault-exclusive') {
+ continue;
+ }
+
+ templateVarInput.setAttribute(attr, attributes[attr]);
+ }
+ }
}
const vaultFieldActions = makeVaultFieldActions(formElement);