function recipe_unit_options in Recipe 7.2
Same name and namespace in other branches
- 5 recipe.module \recipe_unit_options()
- 6 recipe.module \recipe_unit_options()
- 7 recipe.module \recipe_unit_options()
Returns a cached array of recipe unit types.
2 calls to recipe_unit_options()
- recipe_field_widget_form in ./
recipe.module - Implements hook_field_widget_form().
- recipe_field_widget_settings_form in ./
recipe.module - Implements hook_field_widget_settings_form().
File
- ./
recipe.module, line 974 - 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;
}