Skip to content

Commit 04c1f60

Browse files
committed
conflict resolution now properly shows values from any field type
1 parent bbe4c36 commit 04c1f60

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

admin/forms/edit_submission.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
$failed_validation = false;
5757
$changed_fields = array();
5858

59+
5960
if (isset($_POST) && !empty($_POST)) {
6061

6162
if (isset($_POST["core__reconcile_changed_fields"])) {
@@ -156,7 +157,6 @@
156157
Sessions::clear("conflicted_user_values");
157158
Submissions::trackCurrentEditSubmissionFields($grouped_fields, $submission_id, $view_id, $tab_number);
158159
} else {
159-
160160
$user_values = array();
161161
foreach ($changed_fields as $changed_field_name => $changed_info) {
162162
foreach ($grouped_fields as $group) {
@@ -187,11 +187,10 @@
187187
}
188188
}
189189
}
190-
191190
Sessions::set("conflicted_user_values", $user_values);
192191
}
193192

194-
$page_field_ids = array();
193+
$page_field_ids = array();
195194
$page_field_type_ids = array();
196195
$page_has_required_fields = false;
197196
foreach ($grouped_fields as $group) {
@@ -283,12 +282,12 @@
283282
"phrase_please_confirm", "word_no", "word_yes", "word_close", "phrase_validation_error"
284283
)
285284
);
286-
$page_vars["head_string"] =<<< EOF
285+
$page_vars["head_string"] =<<< END
287286
<script src="$root_url/global/scripts/manage_submissions.js"></script>
288287
<script src="$root_url/global/scripts/field_types.php"></script>
289288
<link rel="stylesheet" href="$root_url/global/css/field_types.php" type="text/css" />
290289
$shared_resources
291-
EOF;
290+
END;
292291
$page_vars["head_js"] =<<< END
293292
$validation_js
294293
END;

global/code/FieldTypes.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,7 @@ public static function getFieldTypeProcessingInfo()
705705

706706

707707
/**
708-
* Used in the ft_update_submission function. This retrieves all setting information for a
709-
* field - including the field type settings that weren't overridden.
708+
* This retrieves all setting information for a field - including the field type settings that weren't overridden.
710709
*
711710
* @param $field_ids
712711
* @return array a hash of [field_id][identifier] = values

global/code/Submissions.class.php

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,11 @@ public static function getChangedFieldsSinceLastRender($form_id, $view_id, $subm
15501550
return array();
15511551
}
15521552

1553+
// expensive operations, so just load them once if need by
1554+
$form_fields = array();
1555+
$field_types_processing_info = array();
1556+
$field_settings = array();
1557+
15531558
$changed = array();
15541559
foreach ($view_fields as $field_name => $value) {
15551560

@@ -1558,17 +1563,29 @@ public static function getChangedFieldsSinceLastRender($form_id, $view_id, $subm
15581563
continue;
15591564
}
15601565

1561-
if ($last_edit_submission_state["data"][$field_name] !== $value &&
1562-
$value !== $post[$field_name]) {
1566+
if ($last_edit_submission_state["data"][$field_name] !== $value && $value !== $post[$field_name]) {
1567+
1568+
if (empty($form_fields)) {
1569+
$form_fields = Fields::getFormFields($form_id);
1570+
$field_types_processing_info = FieldTypes::getFieldTypeProcessingInfo();
1571+
1572+
// this gets all settings for the fields, taking into account whatever has been overridden
1573+
$field_ids = (!empty($post["field_ids"])) ? explode(",", $post["field_ids"]) : array();
1574+
$field_settings = FieldTypes::getFormFieldFieldTypeSettings($field_ids, $form_fields);
1575+
}
15631576

1564-
// TODO here we need to construct a new user_value (i.e. what's going to be stored in the database for the users
1565-
// current submission). There, the field type rendering method will handle displaying it appropriately. This
1566-
// should work for all field types.
1567-
// list ($value, $file_field) = self::getSaveFieldValueFromUpdateRequest($post, $form_field, $field_settings, $field_types_processing_info);
1577+
$form_field = array();
1578+
foreach ($form_fields as $row) {
1579+
if ($row["field_name"] == $field_name) {
1580+
$form_field = $row;
1581+
break;
1582+
}
1583+
}
1584+
list ($user_value, $file_field) = self::getSaveFieldValueFromUpdateRequest($post, $form_field, $field_settings, $field_types_processing_info);
15681585

15691586
$changed[$field_name] = array(
15701587
"db_value" => $value,
1571-
"user_value" => $post[$field_name] // TODO this is what changes
1588+
"user_value" => $user_value
15721589
);
15731590
}
15741591
}

0 commit comments

Comments
 (0)