How do form #states interact with dialog action buttons, if at all?

by Mrweiner   Last Updated May 22, 2020 21:07 PM

A dialog can be fired by a link formatted as such:

<a class="use-ajax" 
    Some path displayed in modal dialog.

If the contents of /some/path are a form, then drupal takes its action buttons and drops them into a "footer" <div class="ui-dialog-buttonset"></div> in the dialog. This seems to take into account the initial state of the buttons -- so if submit has the disabled attribute by default then the corresponding UI button gets the .is-disabled class applied. The "real" form action buttons are rendered but set to display: none.

However, I've got #states set up on my submit button with

$form['actions']['submit']['#states'] = [
  'disabled' => [
    ':input[name="field_fivestar_rating[0][rating]"]' => [
        ['value' => '-'],
        ['value' => '0'],

The "real" form submit button is updated correctly according to its #states attribute, but the same cannot be said for the corresponding dialog button. It seems to be static based on the initial state of the submit button.

Is this expected behavior? If so, is this something that deserves an issue in the queue? Seems like an oversight and usability concern.

Related Questions

Form type specific field with modal select

Updated February 19, 2019 13:07 PM

Update element form when modal closed

Updated December 04, 2018 16:07 PM