function farm_soil_disturbance_form_validate in farmOS 7
Soil disturbance quick form validate.
File
- modules/
farm/ farm_soil/ farm_soil.farm_quick.disturbance.inc, line 260 - Farm soil disturbance quick form.
Code
function farm_soil_disturbance_form_validate($form, &$form_state) {
// Alias $form_state['values']['disturbance'] for easier use.
$form_values = array();
if (!empty($form_state['values']['disturbance'])) {
$form_values =& $form_state['values']['disturbance'];
}
// If the area measurement type is "dimensions", length and width are
// required.
if (!empty($form_values['area']['measurement']) && $form_values['area']['measurement'] == 'dimensions') {
if (empty($form_values['area']['size']['length']) || !is_numeric($form_values['area']['size']['length'])) {
form_set_error('disturbance][area][size][length', t('Area length is required.'));
}
if (empty($form_values['area']['size']['width']) || !is_numeric($form_values['area']['size']['width'])) {
form_set_error('disturbance][area][size][width', t('Area width is required.'));
}
}
// Ensure that the area percentage is between 1 and 100.
$percentage = $form_values['area']['percentage'];
if ($percentage < 1 || $percentage > 100) {
form_set_error('disturbance][area][percentage', t('Percentage must be between 1 and 100.'));
}
}