• Hello,
    I’ve discovered a very annoying bug while trying to delete a file (in my case an image) fro a fieldset.

    my CFT code
    [cft_group_fieldset]
    type = fieldset_open
    multiple = true
    multipleButton = true
    mediaRemove = true

    [cft_group_photo]
    label = select a photo
    type = file
    hideKey = true
    mediaButton = true
    mediaLibrary = true
    relation=true

    [cft_group_alt]
    type= text
    label= alt text
    hideKey = true

    [cft_group_fieldset]
    type = fieldset_close

    in functions.php and in single.php I used the code proposed here:

    https://www.kevinleary.net/multiple-fields-groups-wordpress-custom-field-template-plugin/

    if( !function_exists('get_cft_repeating_data') ){
    	function get_cft_repeating_data( $like_item ){
    		global $post, $wpdb;
    
    		$sql = "SELECT * FROM $wpdb->postmeta	WHERE post_id = $post->ID AND meta_key LIKE '%" . $like_item . "%' ORDER BY meta_id ASC";
    
    		$data_objects = $wpdb->get_results($sql);
    		$project = array();
    		$i = 0;
    		$fieldset = $like_item . '_fieldset';
    		foreach($data_objects as $data) {
    
    			// the name of the fieldset:
    
    			if ( $data->meta_key == $fieldset ) {
    				$limit = $data->meta_value - 1;
    			}
    
    			$i = ( $i <= $limit ) ? $i : 0;
    
    			if( $data->meta_key != $fieldset && $data->meta_value !='' ) {
    				$project[$i]["$data->meta_key"] = $data->meta_value;
    			}
    			$i++;
    		}
    
    		if(!$limit && is_user_logged_in() )
    			echo 'Could not establish Custom Field Limit. The $like_item set was ' .$like_item . '<br /> SQL query was ' . $sql;
    
    		return $project;
    	}
    }

    Everything works well till the moment I try to delete an image previously uploded.
    As I refresh/reload my post the img is still there, and I have an error message in my site page (frontend).
    Could not establish Custom Field Limit. The $like_item set was cft_group
    SQL query was SELECT * FROM lmyrph0_postmeta WHERE post_id = 101 AND meta_key LIKE ‘%cft_group%’ ORDER BY meta_id ASC

    In addition Media picker is buggy and doesn’t work ??

    Any suggestions please?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Custom Field Template] bug when deleting a type=file in a fieldset (1 p’ is closed to new replies.