I have a field that is an entity reference on a piece of content. I created a view that is an Entity Reference Source
and set the reference type on the field to that view. When editing the content, I see my list of checkboxes using that Entity Reference Source
view.
The data in the list are tournaments. Once a tournament is completed, I do not want the user to be able to uncheck that tournament when editing the content. They can only toggle "upcoming" tournaments.
I have tried doing a form alter, but each option
in $form['field_tournament']['widget']['#options']
appears to be a DrupalCoreFieldFieldFilteredMarkup
so I cant actually disable the row since its just HTML markup which only includes the label, not the checkbox.
function MYMODULE_form_group_league_edit_form_alter(&$form, FormStateInterface $form_state) { foreach ($form['field_tournaments']['widget']['#options'] as $key => $option) { // disable here if the tournament is set to completed. } }
I understand in the view, I can set to only show "upcoming" tournaments, but I want the ability for them to see which ones have been completed while editing.