Making radio buttons display side by side

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Making radio buttons display side by side

Post by shasta59 » 2013-01-20 02:48

I could not find how to do this in the help files for appgini so here is how I did it.

I wanted radio button to display side by side rather than vertical for a number of reason. Look mostly after I revised the template file.

Here is how to do it with an actual code from a project of mine. Open up the tablename_dml.php file and look for the following:

function clinic_reg_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $ShowCancel = 0){
// function to return an editable form for a table records
// and fill it with data of record whose ID is $selected_id. If $selected_id
// is empty, an empty form is shown, with only an 'Add New'
// button displayed.


Then further down look for the name of your field in the table: I am using year_level_obtained. I want the years to be side by side, not vertical to fit in my design better. The line in red is the one which controls how many radio buttons are shown per line. Since I revise the template files for a better look I need the radio buttons spread out wider on the page.

$combo_year_level_obtained = new Combo;
$combo_year_level_obtained->ListType = 0;
$combo_year_level_obtained->MultipleSeparator = ', ';
$combo_year_level_obtained->ListBoxHeight = 10;

$combo_year_level_obtained->RadiosPerLine = 4;
if(is_file(dirname(__FILE__).'/hooks/clinic_reg.year_level_obtained.csv')){
$year_level_obtained_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/clinic_reg.year_level_obtained.csv')));
$combo_year_level_obtained->ListItem = explode('||', convertLegacyOptions($year_level_obtained_data));
$combo_year_level_obtained->ListData = $combo_year_level_obtained->ListItem;
}else{
$combo_year_level_obtained->ListItem = explode('||', convertLegacyOptions("Never;;Prior to 2007;;2007;;2008;;2009;;2010;;2011"));
$combo_year_level_obtained->ListData = $combo_year_level_obtained->ListItem;
}
$combo_year_level_obtained->SelectName = 'year_level_obtained';
$combo_year_level_obtained->AllowNull = false;


One more thing, while I am at it, if you find that a radio button named 'None' shows up you can get rid of it by adding the AllowNull line to the code at the end of this string. See the last line above. Change year_level_obtained to your field name. If I have multiple files I need to change then I use a program which searches for all instances and allows me to change them in one go. On the macintosh I use BBedit.

Hope someone finds this useful.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

mark4pros
Posts: 4
Joined: 2013-02-07 20:13

Re: Making radio buttons display side by side

Post by mark4pros » 2013-02-07 20:20

Very useful

Thanks Alen.

basti52
Posts: 4
Joined: 2016-04-14 15:53

Re: Making radio buttons display side by side

Post by basti52 » 2016-04-26 21:04

thanks Alan for sharing this!

xbox2007
Veteran Member
Posts: 129
Joined: 2016-12-16 16:49

Re: Making radio buttons display side by side

Post by xbox2007 » 2017-04-09 15:49

hello
thanks a lot
but i think you should change

$combo_year_level_obtained->ListType = 0;
to

$combo_year_level_obtained->ListType = 2;

Drop-Down list = 0
Multiple-choice list box =1
Radio Buttons = 2

Sai chi
Posts: 19
Joined: 2017-08-26 15:29

Re: Making radio buttons display side by side

Post by Sai chi » 2017-10-23 02:20

shall I put the line in red in between this code?

function Property_init(&$options, $memberInfo, &$args){


return TRUE;

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Making radio buttons display side by side

Post by peebee » 2017-10-23 23:24

This is not a hook function. You just need to edit one line in the generated your-table-name.dml file (where your-table-name is the actual name of your table)

Find the code in your-table-name.dml that looks like this, for the particular field with the radio buttons (where your-field-name is the actual name of your field)

Code: Select all

	// combobox: your-field-name
	$combo_your-field-name = new Combo;
	$combo_your-field-name->ListType = 2;
	$combo_your-field-name->MultipleSeparator = ', ';
	$combo_your-field-name->ListBoxHeight = 10;
	$combo_your-field-name->RadiosPerLine = 1;    <= YOU NEED TO EDIT THIS LINE
	if(is_file(dirname(__FILE__).'/hooks/your-table-name.your-field-name.csv')){
		$your-field-name_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/your-table-name.your-field-name.csv')));
		$combo_your-field-name->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions($your-field-name_data)));
		$combo_your-field-name->ListData = $combo_your-field-name->ListItem;
	}else{
		$combo_your-field-name->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("1;;2;;3;;4;;5;;6;;7;;8;;9;;10")));
		$combo_your-field-name->ListData = $combo_your-field-name->ListItem;
	}
	$combo_your-field-name->SelectName = 'your-field-name';
Then just edit the number you see in this line:

$combo_your-field-name->RadiosPerLine = 1;

If you want 5 radio buttons per line, just edit to:

$combo_your-field-name->RadiosPerLine = 5;

Sai chi
Posts: 19
Joined: 2017-08-26 15:29

Re: Making radio buttons display side by side

Post by Sai chi » 2017-10-24 09:40

thanks. I got it!

Sai chi
Posts: 19
Joined: 2017-08-26 15:29

Re: Making radio buttons display side by side

Post by Sai chi » 2018-02-11 08:36

I find that if I saved this setting and restart the computer, My setting will clear up, how can I fix this problem?

Post Reply