diff --git a/includes/evf-core-functions.php b/includes/evf-core-functions.php index c1ca54f6f..9853d393b 100644 --- a/includes/evf-core-functions.php +++ b/includes/evf-core-functions.php @@ -974,6 +974,8 @@ function evf_html_attributes( $id = '', $class = array(), $datas = array(), $att $id = trim( $id ); $parts = array(); + $is_edit_entry = isset( $_GET['edit-entry'] ) && ! sanitize_text_field( wp_unslash( empty( $_GET['edit-entry'] ) ) ) ? true : false; + if ( ! empty( $id ) ) { $id = sanitize_html_class( $id ); if ( ! empty( $id ) ) { @@ -984,6 +986,10 @@ function evf_html_attributes( $id = '', $class = array(), $datas = array(), $att if ( ! empty( $class ) ) { $class = evf_sanitize_classes( $class, true ); if ( ! empty( $class ) ) { + // While editing hidden field should be visible. + if ( $is_edit_entry ) { + $class = str_replace( 'evf-field-hidden', '', $class ); + } $parts[] = 'class="' . $class . '"'; } } @@ -1003,7 +1009,12 @@ function evf_html_attributes( $id = '', $class = array(), $datas = array(), $att } else { $escaped_att = sanitize_html_class( $att ); } - $parts[] = $escaped_att . '="' . esc_attr( $val ) . '"'; + // While editing, fields must be visible even if they are hidden. + if ( 'style' == $escaped_att && $is_edit_entry ) { + $parts[] = 'style = "display: block"'; + } else { + $parts[] = $escaped_att . '="' . esc_attr( $val ) . '"'; + } } } } diff --git a/includes/fields/class-evf-field-hidden.php b/includes/fields/class-evf-field-hidden.php index 98dfc2db8..7788b6be5 100644 --- a/includes/fields/class-evf-field-hidden.php +++ b/includes/fields/class-evf-field-hidden.php @@ -82,9 +82,14 @@ public function field_display( $field, $field_atts, $form_data ) { // Define data. $primary = $field['properties']['inputs']['primary']; + // For edit purpose. + $is_edit_entry = isset( $_GET['edit-entry'] ) && sanitize_text_field( wp_unslash( $_GET['edit-entry'] ) ) ? true : false; + $field_type = $is_edit_entry ? 'text' : 'hidden'; + // Primary field. printf( - '', + '', + $field_type, evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ) ); }