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

Issue #2227513 by e0ipso, Wim Leers: Apply formatters and widgets to Shortcut base fields.

parent af9cd0fd
No related branches found
No related tags found
No related merge requests found
......@@ -151,9 +151,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setRequired(TRUE);
$fields['title'] = FieldDefinition::create('string')
->setLabel(t('Title'))
->setLabel(t('Name'))
->setDescription(t('The name of the shortcut.'))
->setTranslatable(TRUE);
->setRequired(TRUE)
->setTranslatable(TRUE)
->setSettings(array(
'default_value' => '',
'max_length' => 255,
))
->setDisplayOptions('form', array(
'type' => 'string',
'weight' => -10,
'settings' => array(
'size' => 40,
),
));
$fields['weight'] = FieldDefinition::create('integer')
->setLabel(t('Weight'))
......
......@@ -28,16 +28,6 @@ class ShortcutFormController extends ContentEntityFormController {
public function form(array $form, array &$form_state) {
$form = parent::form($form, $form_state);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $this->entity->getTitle(),
'#size' => 40,
'#maxlength' => 255,
'#required' => TRUE,
'#weight' => -10,
);
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
......@@ -54,19 +44,6 @@ public function form(array $form, array &$form_state) {
'#languages' => Language::STATE_ALL,
);
$form['shortcut_set'] = array(
'#type' => 'value',
'#value' => $this->entity->bundle(),
);
$form['route_name'] = array(
'#type' => 'value',
'#value' => $this->entity->getRouteName(),
);
$form['route_parameters'] = array(
'#type' => 'value',
'#value' => $this->entity->getRouteParams(),
);
return $form;
}
......
......@@ -55,7 +55,7 @@ public function testShortcutLinkAdd() {
foreach ($test_cases as $test) {
$title = $this->randomName();
$form_data = array(
'title' => $title,
'title[0][value]' => $title,
'path' => $test['path'],
);
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
......@@ -109,7 +109,7 @@ public function testShortcutLinkRename() {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title' => $new_link_name, 'path' => $shortcut->path->value), t('Save'));
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $new_link_name, 'path' => $shortcut->path->value), t('Save'));
$saved_set = shortcut_set_load($set->id());
$titles = $this->getShortcutInformation($saved_set, 'title');
$this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name);
......@@ -127,7 +127,7 @@ public function testShortcutLinkChangePath() {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title' => $shortcut->getTitle(), 'path' => $new_link_path), t('Save'));
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $shortcut->getTitle(), 'path' => $new_link_path), t('Save'));
$saved_set = shortcut_set_load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'path');
$this->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
......
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