Commit 2e992d56 authored by webchick's avatar webchick

Issue #2324825 by jibran, dawehner, Berdir: Fixed...

Issue #2324825 by jibran, dawehner, Berdir: Fixed MenuLinkContent::baseFieldDefinitions() sets default values incorrectly.
parent b025761f
......@@ -278,7 +278,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setRequired(TRUE)
->setTranslatable(TRUE)
->setSettings(array(
'default_value' => '',
'max_length' => 255,
))
->setDisplayOptions('view', array(
......@@ -297,7 +296,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDescription(t('Shown when hovering over the menu link.'))
->setTranslatable(TRUE)
->setSettings(array(
'default_value' => '',
'max_length' => 255,
))
->setDisplayOptions('view', array(
......@@ -341,7 +339,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['weight'] = BaseFieldDefinition::create('integer')
->setLabel(t('Weight'))
->setDescription(t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.'))
->setSetting('default_value', 0)
->setDefaultValue(0)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'integer',
......@@ -355,7 +353,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['expanded'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Show as expanded'))
->setDescription(t('If selected and this menu link has children, the menu will always appear expanded.'))
->setSetting('default_value', FALSE)
->setDefaultValue(FALSE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'boolean',
......@@ -369,7 +367,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['enabled'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Enabled'))
->setDescription(t('A flag for whether the link should be enabled in menus or hidden.'))
->setSetting('default_value', TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'boolean',
......
......@@ -253,6 +253,9 @@ function doMenuTests() {
$this->drupalGet('admin/structure/menu');
$this->assertLinkByHref('admin/structure/menu/manage/' . $menu_name . '/add', 0, "The add menu link button url is correct");
// Verify form defaults.
$this->doMenuLinkFormDefaultsTest();
// Add menu links.
$item1 = $this->addMenuLink('', 'node/' . $node1->id(), $menu_name, TRUE);
$item2 = $this->addMenuLink($item1->getPluginId(), 'node/' . $node2->id(), $menu_name, FALSE);
......@@ -420,6 +423,23 @@ function doMenuTests() {
$this->items[] = $item2;
}
/**
* Ensures that the proper default values are set when adding a menu link
*/
protected function doMenuLinkFormDefaultsTest() {
$this->drupalGet("admin/structure/menu/manage/tools/add");
$this->assertResponse(200);
$this->assertFieldByName('title[0][value]', '');
$this->assertFieldByName('url', '');
$this->assertNoFieldChecked('edit-expanded-value');
$this->assertFieldChecked('edit-enabled-value');
$this->assertFieldByName('description[0][value]', '');
$this->assertFieldByName('weight[0][value]', 0);
}
/**
* Adds and removes a menu link with a query string and fragment.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment