I have been unable to get the checked state of my radio buttons to save after saving the config form for a repository hook. I select a radio button, and then hit Save and when I go back into the config form for the hook, neither of the radio buttons are checked.
What I've tried :
What do I need to do to make these radio buttons act normally?
{call aui.form.radioField} {param id : 'radio-field' /} {param legendContent: 'Include/Exclude' /} {param fields: [[ 'id' : 'include', 'value' : 'radio-1', 'labelText': 'Include', 'isChecked': $config['include'] ],[ 'id' : 'exclude', 'value' : 'radio-2', 'labelText': 'Exclude', 'isChecked': $config['exclude'] ]] /} {param isRequired: true /} {param descriptionText: 'description' /} {/call}
Community moderators have prevented the ability to post new answers.
If anyone is wondering, I solved this by debugging how the values were saved in the Settings object. Turns out it was saving to the Map in Settings with 'radio-field' as the key and 'radio-1' or 'radio-2' as the value. So I made ternary operators (see code) to solve my problem and now the checked states of the buttons saves correctly.
{call aui.form.radioField} {param id : 'radio-field' /} {param legendContent: 'Include/Exclude' /} {param fields: [[ 'id' : 'include', 'value' : 'include', 'labelText': 'Include', 'isChecked': ($config['radio-field'] == 'include') ? true : false ],[ 'id' : 'exclude', 'value' : 'exclude', 'labelText': 'Exclude', 'isChecked': ($config['radio-field'] == 'exclude') ? true : false ]] /} {param isRequired: true /} {param descriptionText: 'description' /} {/call}
I'm not sure why this works this way exactly, seems the way I wrote my code originally should have worked but I might be missing something. In any case, I solved it this way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.