How to link data from an actor to it's sheet?

Author: JulesLetters

Message: Honestly, I think I might need a version of the tutorial that just dumps everything on me all at once. I’m trying to figure out the connection points to make a default value from template.json show up over in the HTML, and the proper way to have it wired. I went slow and careful through the many wiki tutorial pages… and things just flat out don’t work 🤷 Maybe I got too fancy trying to have an Object in there, but I’m no JS noob (I’m a dev by profession) so I figured it would be straightforward. Alas.

Author: JulesLetters
Message:

I’m attempting to have an object that contains group data (for targeting reasons) on my characters and npcs, and have that changeable in a ‘programming’ tab on the Actor sheet. I got the tab appearing a-okay and the text box shows up, but it seems to link… somewhere into the ether? It persists when I close Foundry, but worrisomely I don’t know where it goes :laughing:

Author: Spacemandev
Message:

<@!252550566184615937> do you have a getData() method? that’s where the link magic happens

Author: zeel
Message:

Yeah, if you’re extending Application (actually not sure if it goes that deep) or one of its children, they use that to pass Handlebars your data.

Author: JulesLetters
Message:

The getData() method inside actor-sheet?

Author: zeel
Message:

Override it, start by calling the parent version to get a data object to work with, tack on your stuff, and return data

Author: zeel
Message:

The rendering part of the class you’re inheriting from calls getData() to get the data to give the template. So as long as you include your data in the object returned from it, you should be good.

Author: JulesLetters
Message:

Ah, it’s lovely to skip so much digging! Thank you! I see it now. What’s the data’s “return trip” path to the DB?

Author: Spacemandev
Message:

<@!252550566184615937> that would be the updateObject override

  _updateObject(event, formData) {
    console.log("Event: ", event);
    console.log("Form Data: ", formData);

    this.object.update(formData);
  }