[turba] Radio buttons, checkboxes, pulldown lists in Turba

Eric spamsink at scoot.netis.com
Sat Nov 25 06:18:33 PST 2006


Good morning, all...

I need to add some radio buttons, checkboxes, and pulldown lists to my 
Turba address book using a MySQL backend.

In the mailing list archives I have found one example that the article 
writer said resulted in an error message:

$attributes['primaryLocation'] = array(
	'label' => _("Primary Location"),
	'type' => 'radio',
	'required' => false,
	'params' => array('Home', 'Work')
);

The error that he cited was "Warning: Invalid argument supplied for 
foreach() in /usr/home2/hordexp/lib/Form/Renderer.php on line 747.".

Another example I found in the archives was:

$attributes['currency'] = array(
      'label' => 'aLabel',
      'type' => 'enum',
      'params' => array(array('EUR' => 'EUR', 'USD' => 'USD')),
      'required' => false
);

This was in response to another question about pulldown lists and 
checkboxes, but the answer didn't indicate to which type it applied.

That's all I was able to find in the archives.

So, as regards radio buttons, how are they stored in the MySQL 
database?  In the "primaryLocation" example above, what data type is 
primaryLocation? Is it a text field where the values can hold the text 
strings "Home" or "work"?  Or is it a numeric field that holds 0 for Home, 
or 1 for Work?

Using the above example for "primaryLocation", will my display show two 
radio buttons, one labeled Home and the other labeled Work?  If I change 
'params' to read

'params' => array('Home', 'Work', 'Pub')

... do I then get three radio buttons on the display labeled Home, Work, 
and Pub, with Home=0, Work=1, and Pub=2?  Are they stored in MySQL as 0, 1, 
and 2 in a numeric field, or as "Home", "Work", "Pub" in a text field?

Does anyone know why the poster might have gotten the "Invalid argument 
supplied for foreach()" error message?  I didn't find an answer in the 
archives.

Regarding checkboxes, I read in the archives that a checkbox is 
"straightforward and doesn't even require 'params'".  So, would something 
like this work?

$attributes['am_pm'] = array(
	'label' => _("PM"),
	'type' => 'checkbox',
	'required' => false,
);

Thus, someone might enter a time of day in a text box and check the "PM" 
checkbox to indicate that the time is after noon.

Does MySQL store "am_pm" as a boolean, a numeric field, or a text field?

Regarding pulldown lists ... frankly I don't know where to begin, and 
wasn't able to find anything in the archives.

I need a pulldown list with elements "Eric", "Bill", "Chris", and 
"Unassigned".  Ideally I'd like the selection to store in a MySQL text 
field as shown, but I can live with it if it stores the selection in a 
numeric field as 0 through 3.

If there is some documentation I haven't found yet that describes all of 
this, I'd sure appreciate a pointer or link.

Thanks...




More information about the turba mailing list