Skip to content

Instantly share code, notes, and snippets.

@joachim-n
Created March 18, 2014 18:56
Show Gist options
  • Save joachim-n/9626938 to your computer and use it in GitHub Desktop.
Save joachim-n/9626938 to your computer and use it in GitHub Desktop.
validation handler
$selected_sessions = array();
foreach (array_keys($form_state['values']['timeslots']) as $timeslot_id) {
foreach (array_keys($form_state['values']['timeslots'][$timeslot_id]['rooms']) as $room_id) {
$cell_form_state_value = $form_state['values']['timeslots'][$timeslot_id]['rooms'][$room_id]['session'];
if (!empty($cell_form_state_value)) {
$selected_sessions[$cell_form_state_value][] = array($timeslot_id, $room_id);
}
}
}
foreach ($selected_sessions as $cell_form_state_value => $timeslot_room_pairs) {
if (count($timeslot_room_pairs) > 1) {
foreach ($timeslot_room_pairs as $timeslot_room_pair) {
list($timeslot_id, $room_id) = $timeslot_room_pair;
form_error($form['timeslots'][$timeslot_id]['rooms'][$room_id]['session'], t('Repeated session!'));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment