I have some user entities and I want to make them available as options to choose in a radio button element on a form.
I can populate the options with a username no problem, so visually I can achieve what I want, but I need to be able to get the user entity that was selected in the form submit function, not just the user name.
I've tried loading the entire user entities into the options array but this throws an error.
I need to to do something like below, but instead of 'entity_autocomplete' it needs to be of type 'radio'
$form['user'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'user',
'#title' => t('Assign or Unassign a user'),
];
When using the above code, the user entity is the value of the form element when submitted, I need to achieve the same thing using radio buttons.