@@ -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