0

I have solr search setup on my drupal8 website. I have a view setup that has two pages in it. I have the search box via an exposed form placed as a block in my header region.

What I want to do is to create a new search form that has different text in the submit button and submits the form to a different page than the search form in the header.

Is there a way through the view or display modes to expose a new template so that I can customize the button and action on the form?

More Details

I was able to create a new solr search form by duplicated the "page" in the solr search view. I modified the name and machine name and modified the input-submit.html.twig template to remove the ID from the submit button. I did that because I have a search form in the header region of my website and then adding another form to the page in a Layout Builder with the same id was causing a conflict and chrome was yelling about it. ID's have to be unique after all.

Layout Builder won't let me save the layout though. I had to revert back to the default and then rebuild my page layout in layout builder. I have to add all of the blocks and then I get to save the layout once. I can the form into the page now, but I won't be able to make any changes to the page in the future.

Well, I suppose i can remove the search form, save the layout, go back in and make my changes and then add the search form back to the layout builder. That is not ideal.

Any trick to fix that issue?

Possible Solution, but not ideal

I added the view page block into the Block Layout and restricted to only the page I needed it on. That should work for now, but I would prefer to be able to see all of the content blocks in the Layout Builder.

0

You can use view mode of all content types where you want to show in searching. Best things are

  • Create views modes for all content type
  • assign or enable view mode for that content type
  • create views and use render as the entity with that view mode.
  • Theme based on need or UI/UX
  • Custom form or create a template for search form so you can change the submit template with different UI.
| improve this answer | |
  • How do you create the custom form template? Should I just make a partial file and copy the html of the search form out of the browser? – Robbiegod Feb 25 at 12:34
  • enable theme debugging and check the name of template suggestions or you can use hook_theme to create form template. – Shamsher Alam Feb 26 at 13:05
  • Ok, i have the theme debugging already enabled. I wasn't seeing any additional template names though. I'll try out the hook theme and see if I can tell it a new template name. Thanks! – Robbiegod Feb 26 at 13:09
  • Seems I am able to create a new submit form by just duplicating the page in the solr search view under Views. I am able to modify the value of submit button in the view settings. I also needed to enable exposed form and change the machine name. I've setup a paragraph field to add views to a field. Problem is now it won't let me save my layout in layout builder when i save the layout. – Robbiegod Mar 3 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.