Issue #2303521 by swentel, larowlan | alexpott: Fixed CommentTypeForm allows the entity type to be changed.
parent
cdebbfb7bf
commit
2d3c7f1642
|
@ -88,6 +88,7 @@ class CommentTypeForm extends EntityForm {
|
||||||
'#title' => t('Description'),
|
'#title' => t('Description'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($comment_type->isNew()) {
|
||||||
$options = array();
|
$options = array();
|
||||||
foreach ($this->entityManager->getDefinitions() as $entity_type) {
|
foreach ($this->entityManager->getDefinitions() as $entity_type) {
|
||||||
if ($entity_type->isFieldable()) {
|
if ($entity_type->isFieldable()) {
|
||||||
|
@ -99,7 +100,16 @@ class CommentTypeForm extends EntityForm {
|
||||||
'#default_value' => $comment_type->getTargetEntityTypeId(),
|
'#default_value' => $comment_type->getTargetEntityTypeId(),
|
||||||
'#title' => t('Target entity type'),
|
'#title' => t('Target entity type'),
|
||||||
'#options' => $options,
|
'#options' => $options,
|
||||||
|
'#description' => t('The target entity type can not be changed after the comment type has been created.')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$form['target_entity_type_id_display'] = array(
|
||||||
|
'#type' => 'item',
|
||||||
|
'#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(),
|
||||||
|
'#title' => t('Target entity type'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||||
$form['language'] = array(
|
$form['language'] = array(
|
||||||
|
|
|
@ -76,6 +76,17 @@ class CommentTypeTest extends CommentTestBase {
|
||||||
// Check that the comment type was created in site default language.
|
// Check that the comment type was created in site default language.
|
||||||
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
|
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
|
||||||
$this->assertEqual($comment_type->language()->getId(), $default_langcode);
|
$this->assertEqual($comment_type->language()->getId(), $default_langcode);
|
||||||
|
|
||||||
|
// Edit the comment-type and ensure that we cannot change the entity-type.
|
||||||
|
$this->drupalGet('admin/structure/comment/manage/foo');
|
||||||
|
$this->assertNoField('target_entity_type_id', 'Entity type file not present');
|
||||||
|
$this->assertText(t('Target entity type'));
|
||||||
|
// Save the form and ensure the entity-type value is preserved even though
|
||||||
|
// the field isn't present.
|
||||||
|
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||||
|
\Drupal::entityManager()->getStorage('comment_type')->resetCache(array('foo'));
|
||||||
|
$comment_type = CommentType::load('foo');
|
||||||
|
$this->assertEqual($comment_type->getTargetEntityTypeId(), 'node');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue