This commit is contained in:
Nathan Coad
2016-06-23 10:11:08 +10:00
parent af3660d974
commit f398980225

View File

@@ -372,7 +372,8 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
//iterate over the sessions for that role type //iterate over the sessions for that role type
foreach ($values[$type] as $session_id => $person) { foreach ($values[$type] as $session_id => $person) {
//get the previous value //get the previous value
$previous_value = _booking_studygroup_leadhelp_edit_get_previous_value($form, $type, $session_id); $previous_value = _booking_studygroup_leadhelp_edit_get_previous_value($form, $type, $type . '[' . $session_id . ']');
watchdog('booking_debug', "<pre>Studygroup assignment previous value:\n@info</pre>", array('@info' => print_r( $previous_value, true)));
//compare it against $person //compare it against $person
//if $person is now empty, do a delete query //if $person is now empty, do a delete query
//if $person is now different, run an update query //if $person is now different, run an update query
@@ -383,11 +384,11 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
/** /**
* look through the previous form data and return the matching element * look through the previous form data and return the matching element
*/ */
function _booking_studygroup_leadhelp_edit_get_previous_value(&$form, $type, $session_id) { function _booking_studygroup_leadhelp_edit_get_previous_value(&$form, $type, $name) {
foreach($form['form']['studygroups']['#rows'] as $key => $value) { foreach($form['form']['studygroups']['#rows'] as $key => $value) {
watchdog('booking_debug', "<pre>Studygroup assignment checker for type !type in session !session:\n@info</pre>", //watchdog('booking_debug', "<pre>Studygroup assignment checker for type !type in session !name:\n@info</pre>",
array('!session' => $session_id, '!type' => $type, '@info' => print_r( $value, true))); // array('!session' => $name, '!type' => $type, '@info' => print_r( $value, true)));
return; //return;
if ((!empty($value[$type]['data']['#value'])) && ($value[$type]['data']['#name'] == $name)) { if ((!empty($value[$type]['data']['#value'])) && ($value[$type]['data']['#name'] == $name)) {
//found the correct element, extract the node id //found the correct element, extract the node id
$person = $value[$type]['data']['#value']; $person = $value[$type]['data']['#value'];