I need to make an entity reference field in my form be required based on the state, the code below is working with other fields, but not my entity reference field.
$form['schedule_publish_date'] ['#states'] = array(
'required' => array(
':input[name="moderation_state[0]"]' => array('value' =>"published"),
),
);
this is the source code of the entity reference field. Am I putting in the wrong name for the form item?
<fieldset data-drupal-selector="edit-schedule-publish-date" id="edit-schedule-publish-date" class="js-form-item form-item js-form-wrapper form-wrapper">
<legend>
<span class="fieldset-legend">Schedule Publish Date</span>
</div>
the moderation state is not what I am having trouble reaching. It's the schedule publish date, which is an entity reference and doesnt become "required" when it should.