WordPress.org

Ready to get started?Download WordPress

Forums

Date and Time Picker Field
[resolved] Not showing saved data in edit screen (6 posts)

  1. Mihail Semjonov
    Member
    Posted 1 year ago #

    Hi all,
    I'm using latest (4.2.0) version of ACF and these plugin (but added in throw functions.php (require_once ... );
    so the problem is that when i select a value (datetime or just time) it's not being displaed after saving the post.
    Variable stores in meta (get_field() returned data) but on edit screen there's nothing showing (blank feeld).
    Also I'm using logic to display that field..
    So if anyone knows how to fix plese write down. I need that urgent!!

    http://wordpress.org/plugins/acf-field-date-time-picker/

  2. Mihail Semjonov
    Member
    Posted 1 year ago #

    Becouse no one was answering made changes to file and replaced 1 function in acf4 version.

    function create_field( $field ) {
            $field = array_merge( $this->defaults, $field );
    		extract( $field, EXTR_SKIP ); //Declare each item in $field as its own variable i.e.: $name, $value, $label, $time_format, $date_format and $show_week_number
            global $post;
            $metas = get_post_meta($post->ID);
            $meta_key = '';
            if($metas){
                foreach($metas as $k => $meta){
                    if($meta[0] == $key){
                        $meta_key = $k;
                    }
                }
            }
            $meta_key = ltrim($meta_key,'_');
            $value = get_field($meta_key);
    		if ( $show_date != 'true' ) {
    			echo '<input type="text" value="' . $value . '" name="' . $name . '" class="ps_timepicker" data-picker="' . $picker . '" data-time_format="' . $time_format . '"  title="' . $label . '" />';
    		} else {
    			echo '<input type="text" value="' . $value . '" name="' . $name . '" class="ps_timepicker" data-picker="' . $picker . '" data-date_format="' . $date_format . '" data-time_format="' . $time_format . '" data-show_week_number="' . $show_week_number . '"  title="' . $label . '" />';
    		}
    	}

    The code I'v added is:

    global $post;
            $metas = get_post_meta($post->ID);
            $meta_key = '';
            if($metas){
                foreach($metas as $k => $meta){
                    if($meta[0] == $key){
                        $meta_key = $k;
                    }
                }
            }
            $meta_key = ltrim($meta_key,'_');
            $value = get_field($meta_key);

    That if someone has same problem it's a quick solution..
    but lets hope that plugin developers will fix that isue and make it work right!

  3. jepser
    Member
    Posted 1 year ago #

    Did you change it in the Add-on or ACF directly? I have the same problem, but I think that changing ACF plugin isn't a good idea.

  4. Mihail Semjonov
    Member
    Posted 1 year ago #

    I'v changed it in plugin. In file that stands for working with ACF 4.
    Yes, changing that diractly in plugin might not work after updating, but since i'm requiring it, it woun't be update..
    I just hope that plugin developers will fix these and there would be no need to manualy do such thing.
    As a solution u can dublicate these plugin.. change it name and make 2 fields with date/time and wen will be update and value will show in normal plugin then just turn off your copy plugin and make all fields from the updated plugin.

  5. jepser
    Member
    Posted 1 year ago #

    Good news for you! The latest version works with the latest version of ACF.

    Just update both plugins, I already did it.

    Best regards!

  6. Mihail Semjonov
    Member
    Posted 1 year ago #

    ok. thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.