Update SearchBlock.php

This commit is contained in:
Kyle Huynh 2023-02-10 16:15:15 -05:00 committed by GitHub
parent 0b71b649fc
commit baf239e858
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,6 +87,7 @@ class SearchBlock extends BlockBase {
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['block_id'] = $form_state->getBuildInfo()['callback_object']->getEntity()->id();
$this->configuration['search_view_machine_name'] = $form_state->getValues()['search-attributes']['view_machine_name'];
$this->configuration['search_textfield_label'] = $form_state->getValues()['search-attributes']['search_textfield'];
$this->configuration['search_placeholder'] = $form_state->getValues()['search-attributes']['search_placeholder_textfield'];
@ -97,7 +98,10 @@ class SearchBlock extends BlockBase {
* {@inheritdoc}
*/
public function build() {
return \Drupal::formBuilder()->getForm('Drupal\advanced_search\Form\SearchForm');
$config = $this->getConfiguration();
$blockId = $config['block_id'];
$searchForm = new \Drupal\advanced_search\Form\SearchForm($blockId);
return \Drupal::formBuilder()->getForm($searchForm);
}
}