custom time format doesn't work
- This topic has 4 replies, 2 voices, and was last updated 4 years, 5 months ago by
julian.
-
AuthorPosts
-
May 20, 2021 at 2:37 AM #28310
julian
Participanthi,
can you tell me why this is happening?
[ 'name' => __( 'Datum', 'your-text-domain' ), 'id' => $prefix . 'repeater_datum', 'type' => 'date', 'class' => 'tage-datum', 'js_options' => array( 'dateFormat' => 'dd-mm-yy', 'showButtonPanel' => true, ), 'save_format' => 'Y-m-d', 'save_field' => 1, ],...should save date as "2021-05-20"....
but the array saved in the DB looks like this.
a:2:{i:0;a:1:{s:14:"repeater_datum";s:10:"20-05-2021";}i:1;a:1:{s:14:"repeater_datum";s:10:"21-05-2021";}}
May 20, 2021 at 8:39 PM #28321Long Nguyen
ModeratorHi Julian,
The option
save_formatdoes not work with the group field. On the other hand, using the group which means for store data, not querying so we don't need to save to another format. We've mentioned it here https://metabox.io/create-group-of-custom-fields-with-meta-box-group/May 21, 2021 at 12:53 AM #28330julian
ParticipantThanks Long Nguyen,
i see. for me it doesnt matter in which format the data are saved as long the user can has the same format in the date picker in the frontend form (metabox made from code) and in the backend (metabox made by the UI). so that means i need to edit the backend metabox with...
'js_options' => array( 'dateFormat' => 'yy-mm-dd', 'showButtonPanel' => false, ),but this doesnt work.
what does work is to add the entire field within the js-options. what doesn't work is to add only the js-option to the existing field. whether by https://docs.metabox.io/edit-meta-boxes/or setting Custom settings like here https://docs.metabox.io/extensions/meta-box-builder/#custom-settings. how should the custom settings look like for the js-options?
thank you
May 21, 2021 at 9:58 PM #28365Long Nguyen
ModeratorHi Julian,
If you want to use the custom settings in the Builder, please use the dot notation to apply the
js_optionssettings. See my screenshot https://share.getcloudapp.com/rRuG88GDMay 22, 2021 at 12:52 PM #28373julian
ParticipantHey Long Nguyen,
it works. thank you very very much for your help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.