Page 1 of 1

How can I use Checkbox Form Control as Radio button ?

Posted: Mon Sep 09, 2013 1:24 pm
by Celero
Hi,

I'm using Oxygen API and I would like to edit a specific value from my XML content. I'm trying to edit this value using the CheckBox Form Control (and it works) but I'd like that the checkboxes would be unique. I mean like HTML radio buttons. Is there a way to achieve this behaviour ?

There is my CSS code :

Code: Select all

oxy_editor(
type, check,
edit, "#text",
values, "1,2,3",
columns, 30,
labels, "1,2,3");
Thanks for your answer

Re: How can I use Checkbox Form Control as Radio button ?

Posted: Mon Sep 09, 2013 2:34 pm
by alex_jitianu
Hi,

The check box form control doesn't have such a built in behavior but you can get something similar by using 3 check box form controls instead of just one:

Code: Select all


content: 
oxy_checkbox(edit, "#text", values, "1", uncheckedValues, "1", labels, "First")
oxy_checkbox(edit, "#text", values, "2", uncheckedValues, "2", labels, "Second")
oxy_checkbox(edit, "#text", values, "3", uncheckedValues, "3", labels, "Third");
The user will be able to select only one check box and will not be able to leave all the check boxes unchecked. What's missing is the "radio button" look (the buttons will still look like check boxes).

Another possible solution is for you to implement a custom form control that looks and behaves as required. As a starting point I can send you the JAVA source code for the built in check box form control. Modifying it for your use case should be simple enough. If you want to go on this road please let me know and I will send you the source code.

Best regards,
Alex

Re: How can I use Checkbox Form Control as Radio button ?

Posted: Mon Sep 09, 2013 4:23 pm
by Celero
Thanks for your reply,

It works great with your solution.

Thanks a lot

Re: How can I use Checkbox Form Control as Radio button ?

Posted: Mon Oct 21, 2019 9:23 am
by mu258770
Hi,

I have come across to a similar issue where I need to have multiple check boxes for one particular attribute.

For example, I need to have a, b, c, d as @outputclass attribute. But a &b should be mutually exclusive, but others can co-exist.

That means, @outputclass="a c d" and @outputclass="b c d" is valid, but not "a b c" or "ab d" or a b c d" etc.

Is there a way to do this? If it can be done only using custom form controls, could you send me a sample code of the oxy_check box implementation?

Regards,
Shabeer

Re: How can I use Checkbox Form Control as Radio button ?

Posted: Mon Oct 21, 2019 11:12 am
by alex_jitianu
Hi Shabeer,

The built-in check box form control can't be customized to work in such a fashion. Do you need to create this custom form control for the standalone version or for the Eclipse plugin? Also, please write an email on support@oxygenxml.com so that I can reply and attach the source code to it.

Best regards,
Alex