Make a field state change depending on the moderation state field I am trying to use the states to change another field depending on the moderation state, I tried this, but didn't catch it.

$form['schedule_publish_date'] ['#states'] =  array(
 'invisible' =&gt; array(
  ':input[name="moderation_state"]' =&gt; array('value' =&gt;"published"),
 ),


I'm not sure what the correct field name of the moderation state is, this is the source code &lt;div class="js-form-item form-item js-form-type-select form-type-select js-form-item-moderation-state-0 form-item-moderation-state-0"&gt;
      &lt;label for="edit-moderation-state-0"&gt;Moderation state&lt;/label&gt;
        &lt;select data-drupal-selector="edit-moderation-state-0" aria-describedby="edit-moderation-state-0--description" id="edit-moderation-state-0" name="moderation_state[0]" class="form-select"&gt;&lt;option value="draft" selected="selected"&gt;Draft&lt;/option&gt;&lt;option value="needs_review"&gt;Needs Review&lt;/option&gt;&lt;option value="approved_to_be_published"&gt;Approved to be published&lt;/option&gt;&lt;option value="published"&gt;Published&lt;/option&gt;&lt;/select&gt;
            &lt;div id="edit-moderation-state-0--description" class="description"&gt;
      The moderation state of this piece of content.
    &lt;/div&gt;
  &lt;/div&gt;
Drupal API: function drupal_process_states

Example A where the source fieldtype is a textfield

$form['moderation_state'] = [
  '#type'  =&gt; 'textfield',
  '#title' =&gt; ('Some title'),
];

$form['schedule_publish_date'] = [
  '#type'   =&gt; 'textfield',
  '#title'  =&gt; ('Invisible if ...'),
  '#states' =&gt; ['invisible' =&gt; [':input[name="moderation_state"]' =&gt; ['value' =&gt; "published"],],],
];


Example B where the source fieldtype is a select-field

$form['moderation_state'] = array(
  '#type'          =&gt; 'select',
  '#title'         =&gt; t('Some title'),
  '#options'       =&gt; array('unpublished'=&gt;'unpublished', 'published'=&gt;'published'),
  '#default_value' =&gt; 0,
);

$form['schedule_publish_date'] = [
  '#type'   =&gt; 'textfield',
  '#title'  =&gt; ('Invisible if ...'),
  '#states' =&gt; ['invisible' =&gt; [':input[name="moderation_state"]' =&gt; ['value' =&gt; "published"],],],
];