Add a helper function for getting the default system of measurement: farm_quantity_system_of_measurement().

This commit is contained in:
Michael Stenta 2018-03-21 11:45:48 -04:00
parent 2aa4e58123
commit a453832151
2 changed files with 12 additions and 2 deletions

View File

@ -373,7 +373,7 @@ function farm_area_format_calculated_area($measurement) {
}
// Get the system of measurement.
$unit_system = variable_get('farm_quantity_unit_system', 'metric');
$unit_system = farm_quantity_system_of_measurement();
// Switch through available unit systems and generate a formatted string.
$conversion = '';

View File

@ -86,13 +86,23 @@ function farm_quantity_settings_form($form, &$form_state) {
'metric' => t('Metric'),
'us' => t('US/Imperial'),
),
'#default_value' => variable_get('farm_quantity_unit_system', 'metric'),
'#default_value' => farm_quantity_system_of_measurement(),
);
// Return it as a system settings form.
return system_settings_form($form);
}
/**
* Helper function for loading the default system of measurement.
*
* @return string
* Returns either 'metric' or 'us' (defaults to 'metric').
*/
function farm_quantity_system_of_measurement() {
return variable_get('farm_quantity_unit_system', 'metric');
}
/**
* Define information about available quantity measures.
*