Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Custom Post Fields acting as File Uploads on Entry Edit Page #1971

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions includes/extensions/edit-entry/class-edit-entry-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,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 || 'fileupload' != $field->type ) {
if ( ! $field || $field->get_input_type() !== 'fileupload' ) {
return $value;
}

Expand Down Expand Up @@ -915,13 +915,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 );

Expand Down Expand Up @@ -1509,8 +1513,9 @@ 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' ) ) )

if(
( $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 )
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This release makes it easier to customize search results per-View instead of glo
* Added: Ability to send notifications using Gravity Forms when an entry is deleted by selecting the "GravityView - Entry is deleted" event from the event dropdown in Gravity Forms notifications settings
* 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:__

Expand Down