#StackBounty: #forms How to hide a form element when a datetime widget is filled using #states

Bounty: 50

The following code is working well to hide a button when a textfield is filled, but it is not working when a datetime widget is encoded:

$form['my_button'] = [
  '#type' => 'container',
  'submit' => [
    '#type' => 'submit',
    '#value' => t("Click on me"),
    '#submit' => ['submit_me']),
    '#states' => [
      'visible' => [
        ':input[data-drupal-selector=selector-of-my-text-field]' => [ 
          'filled' => FALSE,
        ],
      ],
    ],
  ],
];

Any hint?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.