I don't know, if there is somebody, who read tasks, that are marked as "resolved". So i create new topic.
In your latest plugin upgrade this "Saved value 0 for switch field when it's off." didn't work. I have reported this probably a month ago.
Your support is very poorly :/
Sorry for the late reply. In the previous topic, I marked it as "resolved" when I pushed the commit that I thought it fixed the bug.
Let me check it again and will reply you soon.
fix is ok. (i must resave every post (thousands of posts)) to work with this.
One more question: if i would like to have default value in "datetime" filed, what can i do? If i set "std => ' '" (white space string), i get "0" ind DB - it's ok?
I'm sorry for the "re-save". You can write a script to help you doing this.
datetime field, if you set
'std' => ' ', then when saving the post without specifying the datetime, it will save exactly as
' ' in the database. Actually, the plugin treats datetime field like a text field, unless you set
'timestamp' => true, which converts datetime into integer. And then in that case, the value is kind of unexpected, cause
' ' is converted to incorrect value.
I have this:
array( 'name' => __( 'Show until', TEXTDOMAIN ), 'id' => $prefix . 'show_until', 'type' => 'datetime', 'size' => 20, 'js_options' => array( 'regional' => 'cz', 'appendText' => '', 'dateFormat' => 'yy-mm-dd', 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => false ) ),
What i have to do, if i would like default (empty?) record in DB (like 0 in switch)? The reason is, that i must query posts with conditional test EXISTS on this field - this is performance issue on larges sites..
I've tried your code and it's working correctly. There is no '0' saved in the DB. Please see my video:
i don't know, how i get 0 in DB with 'std' => ' ', but now it's really empty.. :/ Nevermind. Back to my last question. Is there a way to have default value for field "datetime"?
There is basic setting for fields 'std' .. but how it works? For example i have this:
'name' => __( 'URL', TEXTDOMAIN ),
'id' => $prefix . 'url',
'type' => 'text',
'std' => 'test'
If i don't fill this field and save the post, than this field doesn't exists in DB. I forgot something?
Is there a way to have 'std' setting work with datetime field? If so how?
std is what you want. But it's applied (e.g. show) only when the meta box hasn't saved. So, if you have saved the meta box once, the field won't show the
std value. You can check that with new post, where the meta box hasn't been saved and you'll see the
std value is showing.
OK, thank you for your support.