How to Create & Save Custom Field Values from a Dropdown on Actor sheet?

I am building a custom system for a Hogwarts setting using the Wands & Wizards 5e supplement. I am currently working on the Character Sheets using the boilerplate system, and am trying to add special field properties. My goal is to have each character sheet feature 3 dropdown bars: 1 for Hogwarts House (Race), 1 for Caster Type (Class), and 1 for School of Magic (Subclass). Depending on the selection, the value will automatically save and store itself in that property, and will be used to pull in features later and set classes within the HTML to change the theme of the character sheet (Red for Gryffindor, Green for Slytherin, etc.). Currently, the dropdown selections are visible in the actor sheet, but the options do not save and always reset. I'm not sure what I have overlooked to not get this to work. I have attached images of my template.json file, my actor-sheet.html, and the actor-sheet.mjs file. You'll see in the .mjs file that I am trying to console.log() some messages for troubleshooting purposes, but those don't show up at all. So I am kinda at a loss here and am unsure what to do next. Can anyone help me out? Thank you so much!
No description
No description
No description
Z
Zhell111d ago
It looks to me like they would save just fine. What you do not have is the correct rendering. You are rendering the dropdowns, but you are not selecting the correct option (or any option for that matter). The selectOptions handlebars helper is your friend here.
GS
GM Shyann110d ago
Okay thank you for the advice. I attempted to install a helper to fix this issue and got "some" progress but my issue is not resolved yet. The options for hogwartsHouse are not displaying in the dropdown for the actor sheet (pic 1). The console seems to be correctly loading in the option names and values, however (pic 2). I've included a snippet of the dropdown bar from the actor sheet (pic 3), the helper I wrote in my world.mjs (pic 4), and the data context options that I defined in actor-sheet.mjs (pic 5). I have also tried using inline-handlebar helpers to assist me, but it constantly throws red errors; I don't think inline is something I can do. Do you, or anyone else, have additional insight on how I can fix this at this point? Thanks in advance!
No description
No description
No description
No description
No description
Z
Zhell110d ago
Why did you make your own when you just needed to use selectOptions?
<select name="stuff">
{{selectOptions hogwartsHouseOptions selected=someValue}}
</select>
<select name="stuff">
{{selectOptions hogwartsHouseOptions selected=someValue}}
</select>
GS
GM Shyann110d ago
There doesn't seem to be a selectOptions() helper in the boilerplate, which is why I added my own. I made this adjustment, but its still throwing errors. Do you have a copy of the selectOptions() function you're referring to?
Z
Zhell110d ago
It's added by foundry example above.
GS
GM Shyann110d ago
Well this is what I have in place right now, but unfortunately, the options still arent rendering in the dropdown; they show up as undefinied. Per actor-sheet.html: <select id="hogwarts-house" name="system.attributes.hogwartsHouse.value" > {{selectOptions hogwartsHouseOptions selected=hogwartsHouse}} </select> But this is how it renders in Foundry during testing: <select id="hogwarts-house" name="system.attributes.hogwartsHouse.value"> <option value="undefined"></option><option value="undefined"></option><option value="undefined"></option><option value="undefined"></option> </select>
Z
Zhell110d ago
Try just this:
context.hogwartsHouseOptions = {
gryffindor: "Gryffindor",
hufflepuff: "Hufflepuff",
...
};
context.hogwartsHouseOptions = {
gryffindor: "Gryffindor",
hufflepuff: "Hufflepuff",
...
};
GS
GM Shyann110d ago
Oh my god, this was it! Thank you soooooo much for your help!! I appreciate it, greatly! Seriously so thankful for the lesson and excited to continue with the system dev.
M
Mana109d ago
{{#select}} is also an option. You had nothing that actually selected the current value.
Want results from more Discord servers?
Add your server
More Posts
Finding target when making an attackI’m developing a game system, and can’t figure it out, when there is combat active and a player is tTrying to register a new systemHey everyone, I am new to Foundry system development. I am working with the boilerplate system and hMinimise Document using PrototypeQuick question, I've got no idea what I'm doing so please excuse my ineptitude. Say I have a documenNew to System Development but have done minor module developmentI am trying to see if there is a complete working model of a system that I could use a base to undercalculating range/distanceI am trying to calculate the distance between two tokens to make sure they are in range of one anothPartial RerollI am looking for a way to partially "reroll" a roll. Quick example: Player rolls 2d6 (a 2 and a 5) atiered status effectsIf I have a status effect that can come from an ability, for example, burning comes from an ability Importing an npm package into a foundry systemimport minimist from 'minimist'; That line alone when included in my module's hook file is resultin(Paid) System Dev AssistanceHello, I am developing a new game and would like to build my own game system in foundry vtt. I'm nothow to handle items and effects?I've been working on a system for a game that needs a concept that seems like it might be a good fitAdvice on the general programming model a system should followI'm brand new to foundry dev and I want to make sure I am gaining the correct understanding of the eAdvice for compendium data in a custom systemHello, i'm new here! I was wondering if I could get a little direction for storing data about my gaDialog Box Auto-Closing Upon Opening 2nd TimeI've been appending custom functionality to the simple worldbuilding system. At this time, I'm tryinActor collisionImplementing the homebrew knockback feature. It's almost working but how do I test if two actor tokeActor attributes update on player's sideI can't fathom how to make changes to actor attributes on player's side. According to documentation Sort itemsHello, I am searching for where is stored the data about "items" order, as I would like to order thNewby accepting advice on the Foundry API and Module DevelopmentHeya,im very new to Module development for foundry and im suuuuper rusty in the codding department bHow do I create/modify embedded document types?Let's say I want Items to also have Items embeddedHow do I specify an Array in my template.json?I want schema checking for elements inside of an undefined-length array in my template.json, how do Is is possible to create/change Foundry's document types?For instance, removing "Actor" and "Item" and adding new ones.