Create attribute with multiple fields like pivot?

Hi guys,
is it possible to create something like this with attributes together with an array. So that it’s possible to create multiple, two value entries. To be honest: What I want to do is adding multiple entities with a related number.

This is what I have:
Bildschirmfoto 2020-09-02 um 17.08.46

This is what I need:
Bildschirmfoto 2020-09-02 um 17.05.37

Thanks for helping!

I remember when doing complex CMS/CRM web back offices having the ability to group fields like that, was super useful.

Currently it isn’t possible, but try posting a feature request on the editor repo, it sounds useful:

Hmm, @Leonidas, you probably may do a close one with the new json type that was recently added:

Script.attributes.add('trigger', {
    type: 'json',
    schema: [{
        name: 'lamp',
        type: 'number',
        default: 1
    }, {
        name: 'Kappe',
        type: 'number',
        default: 2
    }]
});

image

Edit:
Its not exactly what was asked, as you can’t really control the number of fields without changing the schema, but this is probably as close as you can get.

1 Like

Yup, the new JSON schema (currently not documented, but it’s coming), it’s a great step in handling complex script attributes.

Though I think the OP was asking for something similar for array fields, which I think isn’t supported, at least now. I would be happy to be wrong, definitely needing this!

Edit: yes @LeXXik, you are right, it works with array fields as well, extremely happy, going to refactor 100++ scripts to use this :slight_smile:

image

2 Likes

Oh, it does? Nice :slight_smile:

1 Like

Hey this looks great! But instead of Kappe and lamp in your example it should be: Entity and Value. At entity I want to add every entity I want like Kappe or lamp. an value should be a number like in your example. (This is Photoshop:) :wink:
image

Hi @Leonidas, did you do that with code? Could you post it?

Yeah, basically copy/pasted the code @LeXXik posted above. In your case it should be something like this (replace MyScript with the name of your script and re-parse):

MyScript.attributes.add('trigger', {
    type: 'json',
    array: true,
    schema: [{
        name: 'Entity',
        type: 'entity',
        default: 1
    }, {
        name: 'Value',
        type: 'number',
        default: 2
    }]
});
1 Like

But how to make an array out of it like in your example?

Got it. I need to add array: true:

TriggerAnimations.attributes.add('trigger', {
    type: 'json',
    array: true,
    schema: [{
        name: 'entity',
        type: 'entity'
    }, {
        name: 'Value',
        type: 'number',
        default: 1
    }]

});
1 Like

Right! Forgot to add it on my code example above, fixed, thanks for posting this.

1 Like