How can I use Checkbox Form Control as Radio button ?

Post here questions and problems related to oXygen frameworks/document types.
Celero
Posts: 2
Joined: Mon Sep 09, 2013 1:17 pm

How can I use Checkbox Form Control as Radio button ?

Post 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
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

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

Post 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
Celero
Posts: 2
Joined: Mon Sep 09, 2013 1:17 pm

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

Post by Celero »

Thanks for your reply,

It works great with your solution.

Thanks a lot
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

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

Post 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
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

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

Post 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
Post Reply