Hi
Ihave created the following custom field, it uses 'Flatpickr' JS library. The form field works ok and inputs the date value and saves it to the database successfully.
My issue is that on the post edit screen this field is blank when going to edit a post? so i assume that the value is not being loaded from the database? how do i get hold of the database value and populate the input value? I assume i need to know how metabox populates other fields on the post edit screen?
public static function html( $meta, $field ) {
return sprintf(
$html = '<input id="' . $targetName .'-' . $fieldType . '" type="text" name="%s" value="%s">
<script>
document.addEventListener("DOMContentLoaded", function(event) {
const fp = flatpickr("#calendar",
{
dateFormat: "Y-m-d H:i",
altInput: true,
altFormat: "d-m-Y"
});
})
</script>
',
$field['field_name'],
$field['id'],
$meta
);
}
Thanks