update item attribute on actorsheet

I have an item type rangedweapon that has a property of consumes
"rangedweapon": {
....
"consumes": {
"type": "ammo",
"target": { "value": "" },
"amount": { "value": 1 }
},
...
"rangedweapon": {
....
"consumes": {
"type": "ammo",
"target": { "value": "" },
"amount": { "value": 1 }
},
...
And I want to allow the user to set the target value to another item id. So on the character sheet I have something like
{{#each rangedweapons as |item|}}
<select name="item.system.consumes.target.value">
{{selectOptions ../ammos selected=item.system.consumes.target.value nameAttr="_id" labelAttr="name" blank="none"}}
</select>
{{/each}}
{{#each rangedweapons as |item|}}
<select name="item.system.consumes.target.value">
{{selectOptions ../ammos selected=item.system.consumes.target.value nameAttr="_id" labelAttr="name" blank="none"}}
</select>
{{/each}}
And this renders the option's correctly with name and id as the value. And I can select it. but when I close and re-open the the character sheet. the item.system.consumes.target.value is still "" any idea what i'm missing or how i might debug this more?
3 Replies
Alkali Metal
Alkali Metal8mo ago
name doesn't work for embedded documents (like items), you'll need to use a change event listener that's created in the actor sheets activateListeners in order to process the data and update the correct item.
bluegreymouse
bluegreymouseOP8mo ago
ahh! okay that makes sense. Thanks, was starting to go crazy
Alkali Metal
Alkali Metal8mo ago
Yeah, it's a tad confusing at first, but I'm glad I could help point ya in the right direction. :)
Want results from more Discord servers?
Add your server