Commit 993ede00 authored by catch's avatar catch

Issue #2845743 by pwolanin, tim.plunkett, AbhishekLal, claudiu.cristea,...

Issue #2845743 by pwolanin, tim.plunkett, AbhishekLal, claudiu.cristea, alexpott: Search form needlessly extends EntityForm
parent 9cf2b355
......@@ -5,6 +5,7 @@
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\RendererInterface;
use Drupal\search\Form\SearchPageForm;
use Drupal\search\SearchPageInterface;
use Drupal\search\SearchPageRepositoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -84,7 +85,7 @@ public function view(Request $request, SearchPageInterface $entity) {
}
$build['#title'] = $plugin->suggestedTitle();
$build['search_form'] = $this->entityFormBuilder()->getForm($entity, 'search');
$build['search_form'] = $this->formBuilder()->getForm(SearchPageForm::class, $entity);
// Build search results, if keywords or other search parameters are in the
// GET parameters. Note that we need to try the search if 'keys' is in
......
......@@ -22,7 +22,6 @@
* "form" = {
* "add" = "Drupal\search\Form\SearchPageAddForm",
* "edit" = "Drupal\search\Form\SearchPageEditForm",
* "search" = "Drupal\search\Form\SearchPageForm",
* "delete" = "Drupal\Core\Entity\EntityDeleteForm"
* }
* },
......
......@@ -2,9 +2,10 @@
namespace Drupal\search\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\search\SearchPageInterface;
/**
* Provides a search form for site wide search.
......@@ -15,10 +16,10 @@
* trigger the search being processed by the controller, and adding in any
* additional query parameters they need to execute search.
*/
class SearchPageForm extends EntityForm {
class SearchPageForm extends FormBase {
/**
* {@inheritdoc}
* The search page entity.
*
* @var \Drupal\search\SearchPageInterface
*/
......@@ -34,7 +35,9 @@ public function getFormId() {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
public function buildForm(array $form, FormStateInterface $form_state, SearchPageInterface $search_page = NULL) {
$this->entity = $search_page;
$plugin = $this->entity->getPlugin();
$form_state->set('search_page_id', $this->entity->id());
......@@ -72,16 +75,7 @@ public function form(array $form, FormStateInterface $form_state) {
// Allow the plugin to add to or alter the search form.
$plugin->searchFormAlter($form, $form_state);
return parent::form($form, $form_state);
}
/**
* {@inheritdoc}
*/
protected function actions(array $form, FormStateInterface $form_state) {
// The submit button is added in the form directly.
return [];
return $form;
}
/**
......
......@@ -110,7 +110,7 @@ public function getHelp();
*
* The core search module only invokes this method on active module plugins
* when building a form for them in
* \Drupal\search\Form\SearchPageForm::form(). A plugin implementing this
* \Drupal\search\Form\SearchPageForm::buildForm(). A plugin implementing this
* will also need to implement the buildSearchUrlQuery() method.
*
* @param array $form
......
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