diff --git a/src/Form/HelpTopicForm.php b/src/Form/HelpTopicForm.php index cdacb72..2e45a6e 100644 --- a/src/Form/HelpTopicForm.php +++ b/src/Form/HelpTopicForm.php @@ -28,13 +28,6 @@ class HelpTopicForm extends EntityForm { protected $helpStorage; /** - * The help topic view builder. - * - * @var \Drupal\Core\Config\Entity\EntityViewBuilderInterface - */ - protected $helpViewBuilder; - - /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface @@ -71,7 +64,6 @@ class HelpTopicForm extends EntityForm { */ public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, MessengerInterface $messenger, TranslationInterface $string_translation) { $this->helpStorage = $entity_type_manager->getStorage('help_topic'); - $this->helpViewBuilder = $entity_type_manager->getViewBuilder('help_topic'); $this->moduleHandler = $module_handler; $this->themeHandler = $theme_handler; $this->messenger = $messenger; @@ -111,7 +103,6 @@ class HelpTopicForm extends EntityForm { public function form(array $form, FormStateInterface $form_state) { /** @var \Drupal\help_topics\HelpTopicInterface $entity */ $entity = $this->entity; - $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Title'), @@ -209,54 +200,10 @@ class HelpTopicForm extends EntityForm { $form['#entity_builders'][] = '::copyTopicFieldsToEntity'; - // Build the preview area, and the preview if it was requested. - // Note that the get() method on $form_state returns a value or NULL, - // so convert it into an actual Boolean. - $show_preview = ($form_state->get('show_preview')) ? TRUE : FALSE; - $form['preview'] = [ - '#type' => 'details', - '#open' => $show_preview, - '#title' => $this->t('Preview'), - ]; - if ($show_preview) { - $form['preview']['build'] = $this->helpViewBuilder->view($entity); - } - return parent::form($form, $form_state); } /** - * {#inheritdoc} - */ - protected function actions(array $form, FormStateInterface $form_state) { - $actions = parent::actions($form, $form_state); - - $actions['preview'] = [ - '#type' => 'submit', - '#value' => $this->t('Update preview'), - '#submit' => [ - '::submitForm', - '::preview', - ], - ]; - - return $actions; - } - - /** - * Form submission handler for the 'preview' action. - * - * @param array $form - * The form array. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The form state. - */ - public function preview(array $form, FormStateInterface $form_state) { - $form_state->set('show_preview', TRUE); - $form_state->setRebuild(); - } - - /** * Copies the topics and dependencies field values to the entity properties. * * This is added to $form['#entity_builders'] in the form builder method. diff --git a/tests/src/Functional/HelpTopicAdminTest.php b/tests/src/Functional/HelpTopicAdminTest.php index 90ca836..3caa966 100644 --- a/tests/src/Functional/HelpTopicAdminTest.php +++ b/tests/src/Functional/HelpTopicAdminTest.php @@ -361,18 +361,11 @@ class HelpTopicAdminTest extends BrowserTestBase { $session->pageTextNotContains('has been added'); $session->pageTextContains('Must be a comma-separated list of existing topic machine names'); - // Fix form and add dependency field. Test preview by adding link HMTL in - // the body, and verifying after clicking the button, the link is rendered. + // Fix form and add dependency field. $this->drupalPostForm(NULL, [ 'related' => '', 'modules' => 'color', - 'body[value]' => $body . ' Main Drupal site', - ], 'Update preview'); - $session = $this->assertSession(); - $session->linkExists('Main Drupal site'); - - // Submit form to add this new topic. - $this->drupalPostForm(NULL, [], 'Save'); + ], 'Save'); $session = $this->assertSession(); $session->pageTextContains('has been added'); $session->linkExists($title);