Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

AUI radio buttons won't save check state

Christian Brown July 7, 2015

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 :

  1. Using only one radio button (with id 'include') --> saves correctly once I remove the id tag from the radioField itself
  2. I added back the second radio button with id  'exclude' and then both could be selected at once but also saved their checked states

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}

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Christian Brown July 7, 2015

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.

 

TAGS
AUG Leaders

Atlassian Community Events