Change Weight for Custom Form Builder Components?
Hello again, When configuring a custom Form Builder, is there a way to change the weight of the actual components themselves? Not the categories, but the components. For example, I would like to just put a collection of components that are in the basic and advanced grouping under one custom "Components" section, but I would like to be able to group them accordingly.
Given this configuration, I would like to group the date/time related components together:
But when they are rendered, they end up like this (with checkbox mixed in between)
Thanks in advance.
You will probably need to also change the "weight" of the other components which is provided in their "builderInfo" method. Something like this may allow you to modify any components builderInfo weight.
var checkBoxInfo = Formio.Components.components.checkbox.builderInfo;
checkBoxInfo.weight = 200;
Object.defineProperty(Formio.Components.components.checkbox, 'builderInfo', {
get() {
return checkBoxInfo;
}
});
Note: I have not actually tested this to see if it works, but I have a hunch it may.
@travist Thanks for your solution, it totally works for me. One more addition to it to make it little optimized
import {Formio} from 'formiojs';
// Sequence
let index = 500;
[
'textfield',
'textarea',
'email',
'selectboxes',
'select',
'phoneNumber',
'radio',
'datetime',
'button',
].forEach(name => {
let component = Formio.Components.components[name].builderInfo;
component.weight = index++;
Object.defineProperty(Formio.Components.components[name], 'builderInfo', {
get() {
return component;
},
});
});
We're currently addressing a backlog of GitHub issues, and as part of this effort, some inactive issues may be marked as closed. This isn't a dismissal, but a step toward more efficient tracking.
If you feel the issue is still relevant, please re-open and we'll ensure it gets the attention it deserves. Your understanding is appreciated as we work to enhance our open-source responsiveness.