Setting Value programatically

Created on 21 March 2023, over 1 year ago
Updated 22 March 2023, over 1 year ago

Hi!
How can I set/target the third element of a multi-value (second subfield) programatically with D9? Thanks for any suggestion

$new_round_data = [
      'type' => 'participations',
      'langcode' => 'en',
      'created' => time(),
      'changed' => time(),
      'uid' => $user_id,
      'title' => $values['round_name'],
      'field_part_stats' => ????
    ];
    $new_round = Node::create($new_round_data);
	//$new_round->field_prof_stats[1]->second = 12;
	//$new_round->field_part_stats[1]->second = 12;
	//$new_round->field_part_stats[0]['second'] = 123;
    $new_round->save();
πŸ’¬ Support request
Status

Closed: works as designed

Version

4.1

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria coreteamvn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024