🇪🇬Egypt ashroof
I faced same issue, I was able to work around by adding form_state to add the smartDate value
here is my code
// date and time values
$startDate = new DateTime('2024-16-03 10:00:00 Am');
$endDate = new DateTime('2024-16-03 10:30:00 Am');
// smartDate array which has all recurring information
$schedule = ["time_wrapper" => ["value" => ["date" => $startDate->format('Y-m-d'), "time" => $startDate->format('H:i:s')], "end_value" => ["date" => $endDate->format('Y-m-d'), "time" => $endDate->format('H:i:s')]],
"duration" => 30,
"timezone" => "UTC",
"repeat" => "WEEKLY", // DAILY - MONTHLY - YEARLY
"repeat-end" => "COUNT",
"repeat-end-count" => "8",
"repeat-end-date" => "", //$endDate
"_weight" => "0",
];
// add node array with node information
$node = array(
'type' => $type,
'created' => time(),
'uid' => $uid,
'title' => $title,
'body' => ['value' => $body],
);
$node = \Drupal::entityTypeManager()->getStorage($entity_type)->create($node);
$node_form_object = \Drupal::entityTypeManager()
->getFormObject('node', 'default')
->setEntity($node);
$form_state = new FormState();
$form_state->setValue('field_event_date', [$schedule]);
$form_state->setValue('op', $this->t('Save'));
$form_state->setValidateHandlers([]);
\Drupal::formBuilder()->submitForm($node_form_object, $form_state);
you can change the $schedule array to meet your recurring rule