Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Default Checkbox User Option

1561586789
MagooChris
Pro
Sheet Author
Hey Sheet Developers, Does anyone know how to set a User Option in the json so that a checkbox option is checked by default? I've tried to just set the default and the value to the same thing, but looks like it hasn't worked. It is annoying that I can't test this without submitting a new pull request and having it applied. "type" : "checkbox" ,              "value" : "1" ,              "default" : "1" , Any help would be appreciated! Regards, MagooChris
1561592867
Finderski
Pro
Sheet Author
Compendium Curator
It should be the value of the actual form in the character sheet.  If you didn't set a value in the character sheet html, then the checkbox value is likely, "on" I hope this helps.
1561593591

Edited 1561593620
vÍnce
Pro
Sheet Author
MagooChris said:  It is annoying that I can't test this without submitting a new pull request and having it applied. Understatement.  ;-\ This is how we have setup a checkbox for one of our attributes on the Pathfinder Community Sheet sheet.json {     "attribute": "is_npc",     "displayname": "IS NPC",     "displaytranslationkey": "is-npc-check-caps",     "type": "checkbox",     "value": "1",     "description": "Sheet is an NPC or Monster",     "descriptiontranslationkey": "is-npc-description" } and the HTML for "is_npc" <input type="checkbox" class="sheet-selectedlabel-check" name="attr_is_npc" value="1" title="@{is_npc}" /> Hope this helps.
1561602747
MagooChris
Pro
Sheet Author
Thanks for the replies, but the checkboxes I have are linked, but what I want to set is that when a new campaign is selected with the Character Sheet, I want some of the checkboxes in the Game Settings to show "Checked" by default.
1561604230
Finderski
Pro
Sheet Author
Compendium Curator
Here's one with a default setting: {             "attribute":"WCI",             "displayname":"Wild Card Icon",             "displaytranslationkey":"wild-card-icon",             "type":"select",             "options":[                 "⊛|⊛",                 "✪|✪",                 "♕|♕",                 "†|†",                 "༒|༒"             ],             "default":"✪",             "description":"Select the Wild Card icon to be used in the Stat Block output.",             "descriptiontranslationkey":"wild-card-icon-desc"         } To set the Default state of the checkbox, you set the "default" to the actual value of the checkbox.  If you didn't specify an actual value in the character sheet's HTML, then use "on" MagooChris said: Thanks for the replies, but the checkboxes I have are linked, but what I want to set is that when a new campaign is selected with the Character Sheet, I want some of the checkboxes in the Game Settings to show "Checked" by default. You can also accomplish this in the character sheet's HTML by simply setting it as checked. <input type="checkbox" class="sheet-useBackground" name="attr_background" value="1" checked />
1561607311
MagooChris
Pro
Sheet Author
Thanks  Finderski , I have all of that already, but it doesn't seem to be working. When I open the Game Settings page all of the checkboxes that I specified the default value on are not checked by default. 
1561635217
Finderski
Pro
Sheet Author
Compendium Curator
Might be easier if you can share what you have?  I'd recommend posting your HTML, CSS, and the JSON stuff you're wanting to use.  That way we can see all the pieces...
1561672995
MagooChris
Pro
Sheet Author
Sure: in Sheet.json: { "attribute" : "run_firstTime_setup" , "displayname" : "Run First Time Setup" , "displaytranslationkey" : "RunFirstTimeSetup-Q" , "type" : "checkbox" ,              "value" : "1" ,              "default" : "1" , "description" : "Run scripts to setup the sheet for a default character." , "descriptiontranslationkey" : "RunFirstTimeSetup-D"         }, Create a new game with this template and in the Game Settings: ^^^^^^^ Why doesn't the "Run First Time Setup" checkbox show as checked? This question has nothing to do with the Character sheet itself, so there is no need to post the html/css of it.
1561697560
GiGs
Pro
Sheet Author
API Scripter
Finderski asked to see the html code etec (not all of it, just the specific parts affected by this default) because there may be something there that explains what's happening. PS: i hope you aren't planning to replace the current fate Core sheet with one based on the D&D sheet. The Fate Core sheet could do with some tweaks for improvment but doesnt need a rewrite so drastic that it invalidates existing data.
1561894413
MagooChris
Pro
Sheet Author
Hi GiGs, I had no intention of replacing the current Fate Core sheet. I built mine in a different folder with a different name so that it would live along side the existing ones. but when I went to get that screenshot I realised that the Roll20 admins have decided to have my sheet replace the existing one, or at least I can't find the other version. I will need to do some extra work then to allow the sheet to upgrade from the previous, unless we can convince the Roll20 Gods to separate the sheets. Seeing you are a Sheet Author yourself, you can check it out under: "Fate Core V2" folder. In terms of the settings, My understanding is that what you have in the sheet.json is the game settings that can be set for any new character sheet that gets created. The link between setting the value in the settings and then creating a new sheet is there, but the default value that I set in the sheet.json does not show up on the game settings page, and I don't own the html for that. Anyway, where it is used in the sheet is a single checkbox:  < input type = "checkbox" value = "1" name = "attr_run_firstTime_setup" checked = "checked" /> but it is used in the worker: on ( 'sheet:opened' , function () { getAttrs ([ "run_firstTime_setup" , "default_stressSkills" , "default_consequences" ], function ( values ) { if ( Number ( values [ "run_firstTime_setup" ]) == 1 ) { Like I said, this part works fine, it is the Game Settings in the GM controls that isn't working. Regards, MagooChris
Hello MagooChris, I have exactly the same issue. It looks like the type "checkbox" is not able to handle the "default" field. I scanned all existing Character Sheets created by roll20 there is NO example of a checkbox ticked by default. They always have them, unchecked, that is they "reverse" the meaning of the checkbox when they need to. That is in your case your checkbox should be called "dont run first time setup". It's a bad practice :) I'm currently trying a workaround, that is use a select with a default value in the user options sheet.json, and keep the input in the html as checkbox. My assumption is the data is stored as string in both cases so that should work.  I'll have to wait for the next pull request approuval :)
1566646107
MagooChris
Pro
Sheet Author
Hey Gronyon,  We actually found the answer to this. It turns out that it just applies the fields to the HTML, so if you want to make it checked by default all you have to do is set Checked in the JSON and it works.  You can see this in my fate core v2 sheet folder. I'm not at home at the moment or I would paste an example.  Regards,  MagooChris 
1566652574

Edited 1566652883
Andreas J.
Forum Champion
Sheet Author
Translator
MagooChris said: ... It turns out that it just applies the fields to the HTML, so if you want to make it checked by default all you have to do is set Checked in the JSON and it works.  You can see this in my fate core v2 sheet folder. I'm not at home at the moment or I would paste an example. Thanks for sharing this discovery! This could also mean that other similar options like disabled="disabled" might also work(not that I'd know why I'd use it). I went and updated the Default Settings wiki page to include this tidbit, and added your code as one of the examples on the page, as it only had links up to this point. Now the documentation should be more helpful.
Excellent ! thanks a lot for the tip ! And thanks Andreas for the doc update ! The disabled could be used to create some "separator" with explanation to what would come next. I'll try it out :)
Well. I couldn't test the disabled="disabled" or readonly="readonly". Each update I send to Roll20 (even those not concerning sheet.json changes) do break the server. Since we have no way to test sheet.json outside of the Roll20 live, I can't tell whether those tricks work.
1571075637
Andreas J.
Forum Champion
Sheet Author
Translator
Gronyon said: Well. I couldn't test the disabled="disabled" or readonly="readonly". Each update I send to Roll20 (even those not concerning sheet.json changes) do break the server. Hoooold up. what if those attempts are what breaks the server? Did you do them as part of some larger update? Have you tried submitting the changes without those disabled="disabled" additions?
1571084726

Edited 1571084809
 (even those not concerning sheet.json changes) Yes I tried submitting all files but the sheet.json. I also totally canceled my branch, and pushed a new branch with new features (in fact features that were removed by accident by another developer on the same character sheet). Also broke.