From b2759ba7a987e43a7fdd516d194284f9f3c5bb17 Mon Sep 17 00:00:00 2001 From: Doeke Norg Date: Tue, 16 Jan 2024 15:39:56 +0100 Subject: [PATCH 1/2] Fixed Custom Post Fields acting as File Uploads on Entry Edit Page --- .../edit-entry/class-edit-entry-render.php | 16 ++++++++++------ readme.txt | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/extensions/edit-entry/class-edit-entry-render.php b/includes/extensions/edit-entry/class-edit-entry-render.php index d0ffe2aefc..ec0ec3f02d 100644 --- a/includes/extensions/edit-entry/class-edit-entry-render.php +++ b/includes/extensions/edit-entry/class-edit-entry-render.php @@ -596,7 +596,7 @@ private function process_save_process_files( $form_id ) { */ public function save_field_value( $value = '', $entry = array(), $field = null, $form = array(), $input_id = '' ) { - if ( ! $field || $field->type != 'fileupload' ) { + if ( ! $field || $field->get_input_type() !== 'fileupload' ) { return $value; } @@ -901,13 +901,17 @@ private function maybe_update_post_fields( $form ) { case 'post_category': break; case 'post_custom_field': - if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { + if ($field->get_input_type() === 'fileupload') { + break; + } + + if ( is_array( $value ) && ( (float) $field_id !== (float) $field->id ) ) { $value = $value[ $field_id ]; } - if( ! empty( $field->customFieldTemplateEnabled ) ) { - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); - } + if( ! empty( $field->customFieldTemplateEnabled ) ) { + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); + } $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); @@ -1470,7 +1474,7 @@ public function modify_edit_field_input( $field_content = '', $field = null, $va // If the form has been submitted, then we don't need to pre-fill the values, // Except for fileupload type and when a field input is overridden- run always!! if( - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) + ( $this->is_edit_entry_submission() && !in_array( $field->get_input_type(), array( 'fileupload', 'post_image' ) ) ) && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) && ! GFCommon::is_product_field( $field->type ) || ! empty( $field_content ) diff --git a/readme.txt b/readme.txt index bed8ccd3bc..e28faef868 100644 --- a/readme.txt +++ b/readme.txt @@ -27,6 +27,7 @@ This release makes it easier to customize search results per-View instead of glo * Fixed: Sorting the View by entry ID in ascending and descending order would yield the same result * Fixed: Survey fields without a rating would show a 1-star rating +* Fixed: Custom Post Field acting as File Uploads can now be edited on the Edit Entry page __Developer Updates:__ From 6c8875a7b6b53a882a6d7c59193ddb3015113751 Mon Sep 17 00:00:00 2001 From: Doeke Norg Date: Thu, 18 Jan 2024 09:40:19 +0100 Subject: [PATCH 2/2] fix code style --- includes/extensions/edit-entry/class-edit-entry-render.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/extensions/edit-entry/class-edit-entry-render.php b/includes/extensions/edit-entry/class-edit-entry-render.php index ec0ec3f02d..176f4254b7 100644 --- a/includes/extensions/edit-entry/class-edit-entry-render.php +++ b/includes/extensions/edit-entry/class-edit-entry-render.php @@ -901,7 +901,7 @@ private function maybe_update_post_fields( $form ) { case 'post_category': break; case 'post_custom_field': - if ($field->get_input_type() === 'fileupload') { + if ( $field->get_input_type() === 'fileupload' ) { break; }