function recipe_unit_options in Recipe 7
Same name and namespace in other branches
- 5 recipe.module \recipe_unit_options()
- 6 recipe.module \recipe_unit_options()
- 7.2 recipe.module \recipe_unit_options()
Returns a cached array of recipe unit types.
2 calls to recipe_unit_options()
- recipe_admin_settings in ./
recipe.admin.inc - Page callback: Constructs a form for configuring the Recipe module.
- recipe_form in ./
recipe.module - Implements hook_form().
File
- ./
recipe.module, line 1075 - Contains functions for Recipe node CRUD and display.
Code
function recipe_unit_options() {
static $options;
if (!isset($options)) {
$units = recipe_get_units(variable_get('recipe_preferred_system_of_measure_limit', 0));
// Put in a blank so non-matching units will not validate and save.
$options = array(
'' => '',
);
foreach ($units as $unit_key => $unit) {
$text = $unit['name'];
if (!empty($unit['abbreviation'])) {
$text .= ' (' . $unit['abbreviation'] . ')';
}
$options[$unit_key] = $text;
}
}
return $options;
}