Add a field to a model from a custom component field property

  • 1
  • Question
  • Updated 1 year ago
  • Answered
In Skuid (most of the time) when I add a rendering condition on a field using a 'field' property in a component, skuid will add that field to the model definition.

I want to do something similar in my custom component. I have a field property, and when the user chooses a field I want to make sure it's in the field property's model, and if it isn't, add it.

How would I go about that?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 1 year ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
Fortunately the answer to this one is incredibly simple:

addFieldToModel: true


:)

e.g. 

{
   type: "field",
   id: "importantfield",
   modelprop: "model",
   addFieldToModel: true,
}
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Love it!