Skip to content

Instantly share code, notes, and snippets.

@edutrul
Last active July 30, 2017 05:45
Show Gist options
  • Save edutrul/a6a3d0da9e17f939165a08516b9cd9bc to your computer and use it in GitHub Desktop.
Save edutrul/a6a3d0da9e17f939165a08516b9cd9bc to your computer and use it in GitHub Desktop.
Implement STATES on drupal8
<?php
$formIds = [
'node_location_form',
'node_location_edit_form',
];
if (in_array($form_id, $formIds)) {
$form['#attached']['library'][] = 'care_location/care_location_node_form';
$form['field_location_google_streetview']['#states'] = [
'visible' => [
':input[name="field_location_what_to_display"]' => ['value' => 'field_location_google_streetview'],
]
];
$form['field_location_images']['#states'] = [
'visible' => [
':input[name="field_location_what_to_display"]' => ['value' => 'field_location_images'],
]
];
$form['field_location_images_modal']['#states'] = [
'visible' => [
':input[name="field_location_what_to_display"]' => ['value' => 'field_location_images'],
]
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment