Jump to content
lele_ballack

Search selectors and empty repetear fields

Recommended Posts

There is something about a search form that I'm unable to solve. 

My search form has a text input that searches through fields of a specific template:

// keyword input
if(isset($input->get->q)) {
  $keyword = $sanitizer->text($input->get('q'));
  $selector .= "title|Abbreviazione|Sottotitolo|Titolo_Testo.Titolo|Titolo_Testo.Testo~%=$keyword, ";
  $input->whitelist("q", $keyword);
}

In this template, there fields are: title, Abbreviazione and Sottotitolo (text fields) and Titolo_Testo (repeater made of text fields Titolo and Testo).

When I search any word, it returns the matching pages, but when I reset my form to (or search) an empty value, it only finds pages where the repeater Titolo_Testo is set and filled. 

How can I instruct it to search for repeaters only if they are set and get all pages results on an empty value search? 

Or else, is there a way to detect an empty search value as isset still returns true?

I'm using PW 3.0.165.

Thanks a lot!

Share this post


Link to post
Share on other sites
3 hours ago, lele_ballack said:

Or else, is there a way to detect an empty search value as isset still returns true?

Maybe something as simple as this will do?

if(isset($input->get->q) && !empty($input->get->q)) {
...
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...