How to add radio buttons in Options page

AndyB

Well-known member
In my Bookmark add-on I currently have the following four selections in the Options page:

pic001.webp

This works, but it's confusing to admins because all four selection can be selected. What I would like to do is make the first two selection be radio Buttons and make the last selection Radio Button.

So how do I set up the edit page?

Edit Format: Radio Buttons
Data Type: Array
Array Sub-Options:

What should I enter into the Array Sub-Options field?

Thank you.
 
As a collection of radio buttons can only have a single value, a data type of "Array" won't work. Only one radio button can be selected at a time, hence only one value can be stored.
 
That would require two options.

One that gives two radio buttons for Post Date and Bookmark Date and another that gives two radio buttons for Sort Descending and Sort Ascending.
 
That would require two options.

One that gives two radio buttons for Post Date and Bookmark Date and another that gives two radio buttons for Sort Descending and Sort Ascending.

Yes exactly what I would like to do. The problem is I have no idea how to set these fields:

pic001.webp
 
As stated, it can't be an array because radio buttons would output a single value.

With that in mind, you should be able to choose an appropriate data type; and if it can't be an array, then maybe Array Sub-Options doesn't need to be set...
 
Look at how an existing radio button option is set up:

admin.php?options/edit-option/jQuerySource
 
Thanks, Chris. I forgot I could look at the edit of existing radio buttons for the clue I needed.

pic001.webp

pic002.webp
 
Top Bottom