CMB2-Date-Range-Field icon indicating copy to clipboard operation
CMB2-Date-Range-Field copied to clipboard

date doesn't show after saving or updating post

Open amitrahav opened this issue 8 years ago • 2 comments

the date is saved in database but it dosent show on post edit page

amitrahav avatar Aug 02 '16 18:08 amitrahav

i plowed through the code to find that this plugin was reading the wrong format from database. Something may have changed in the way cmb2 saves the fields.

so, instead of saving the json format, just save the output. Change line 144 ( on wds-cmb2-date-range-field.php ) to just $escaped_value, Lines: 142-146:

		printf( '<div class="cmb2-element"><input%s value=\'%s\'/></div>%s',
			$field_type->concat_attrs( $a, array( 'desc' ) ),
			$escaped_value,
			$a['desc']
		);

maybe it will solve your problem too.

LC43 avatar Sep 14 '17 18:09 LC43

Hello, I realise that this is an old threat (and perhaps this is an old CMB2 add-on too, so no more updated), so I don't know if it is supported anymore (but this could be very useful add-on). I have the same issues: date doesn't show (in the daterange button) after saving or updating post.

What I've noticed is that:

  • When I edit a post and set the daterange the first time, the date (visible in the datarange button) is stored in the db as follow, e.g.:

{"start":"07/01/2020","end":"07/20/2020"}

  • If lately I enter again the same post (and the date is NO MORE visible in the datarange button), if I update the post without touching the datarange at all, the date stored in the db became as follow:

"{"start":"07\/01\/2020","end":"07\/20\/2020"}"

(...all wrapperd in double-quotes and escaped). So when I retrieve the date, it has a NULL value. Could it be due to the "sanitize" method in the plugin?

paolosax avatar Apr 23 '20 16:04 paolosax