Skip to content
Snippets Groups Projects
Commit de5d27e6 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2427161 by tstoeckler: shortcut.admin.js broken, replace with #states

parent 8c885d4d
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
(function ($) {
"use strict";
/**
* Make it so when you enter text into the "New set" textfield, the
* corresponding radio button gets selected.
*/
Drupal.behaviors.newSet = {
attach: function (context, settings) {
var selectDefault = function () {
$(this).closest('form').find('.form-item-set .form-type-radio:last input').prop('checked', true);
};
$('div.form-item-new input').on('focus', selectDefault).on('keyup', selectDefault);
}
};
})(jQuery);
drupal.shortcut.admin:
version: VERSION
js:
shortcut.admin.js: {}
dependencies:
- core/jquery
- core/drupal
drupal.shortcut:
version: VERSION
css:
......
......@@ -105,9 +105,13 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#title_display' => 'invisible',
'#description' => $this->t('The new set is created by copying items from your default shortcut set.'),
'#access' => $add_access,
'#states' => array(
'visible' => array(
':input[name="set"]' => array('value' => 'new'),
),
),
);
$form['id'] = array(
'#type' => 'machine_name',
......@@ -131,10 +135,6 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter
$form['new']['#description'] = $this->t('The new set is created by copying items from the %default set.', array('%default' => $default_set->label()));
}
$form['#attached'] = array(
'library' => array('shortcut/drupal.shortcut.admin'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment