Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'duplicate' revision log textbox on entity form. #47

Open
wants to merge 1 commit into
base: 8.x-1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/Form/RevisionableContentEntityForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/
class RevisionableContentEntityForm extends ContentEntityForm {

/**
* The class the entity type must extend to use this form.
*/
const REQUIRED_PARENT = 'Drupal\entity\Revision\RevisionableContentEntityBase';

/**
* The entity being used by this form.
*
Expand Down Expand Up @@ -54,6 +59,11 @@ protected function getBundleEntity() {
*/
public function form(array $form, FormStateInterface $form_state) {
$entity_type = $this->entity->getEntityType();
$reflection = new \ReflectionClass($entity_type->getClass());
if (!$reflection->isSubclassOf(self::REQUIRED_PARENT)) {
throw new \Exception('Entity type must implement ' . self::REQUIRED_PARENT);
}
$form = parent::form($form, $form_state);
$bundle_entity = $this->getBundleEntity();
$account = $this->currentUser();

Expand Down Expand Up @@ -100,16 +110,11 @@ public function form(array $form, FormStateInterface $form_state) {
],
];
}
// RevisionLogEntityTrait adds the log message field; move it into tab group.
$form['revision_information']['revision_log_message'] = $form['revision_log_message'];
unset($form['revision_log_message']);

$form['revision_information']['revision_log'] = [
'#type' => 'textarea',
'#title' => $this->t('Revision log message'),
'#rows' => 4,
'#default_value' => $this->entity->getRevisionLogMessage(),
'#description' => $this->t('Briefly describe the changes you have made.'),
];

return parent::form($form, $form_state);
return $form;
}

/**
Expand Down