Problem/Motivation
I know this is a basic question, but I haven't figured it out as of yet and there is very little to nothing about it that I can find on the Interwebs. At the very least, having this info out there will benefit others in the future hopefully. I'm currently on Drupal 9.5.11.
So I am trying to pull in a bunch of data via a feed from our DAMS to create a new image in the Drupal admin. I populate fields programmatically on an add Media screen with the information pulled in. All my data is pulling in great and I have all my fields populated with the needed data *except* the YMD Date field. I've tried a bunch of different ways to populate it, but it remains stubbornly blank. The attached screenshot shows that add media screen I'm using. The "DATE CREATED" field is a ymd_date field. You just fill in the correct record number in that very first field then hit the "Fetch DAMS Record" button and all the data is pulled in and populated to the fields - which is working fine (except this one field).
I've tried populating the individual YYYY MM and DD parts of the ymd_date field separately, and also the whole field together with the YYYYMMDD format. I know the data is there and correct. This is what I've tried (among lots of other things, but I think this is the closest).
Separate components:
$form[$field_key]["widget"][0]["ymd_date"]["year"]["#default_value"] = date('Y',$date_obj); // 4-digit year
$form[$field_key]["widget"][0]["ymd_date"]["month"]["#default_value"] = date('m',$date_obj); // 2-digit month
$form[$field_key]["widget"][0]["ymd_date"]["day"]["#default_value"] = date('d',$date_obj); // 2-digit day
Or, full field:
$form[$field_key]["widget"][0]["#default_value"] = $full_date; // This is in YYYYMMDD format.
Maybe I also need to set the labels of the fields separately? I haven't found any examples anywhere of how to set these fields correctly, and haven't found any documentation except the brief blurb on the project page.
In case it's helpful, the second screenshot shows the "Inspect" of the field.
Can anyone help? Thank you so much!!