Pods - Custom Content Types and Fields
[resolved] How to pass checkbox value to echo $pod->filters() (4 posts)

  1. senyoraangelica
    Posted 1 year ago #

    Hello! I've been looking for a solution for the past few days but I just couldn't figure it out. Under echo $pod->filters(); , I echoed some checkboxes from another pod page which will let visitors search my pods through any custom fields they want:

    <form action="" method="get">
    <input type="checkbox" name="bookauthor" checked="checked">
    	<label for="bookauthor">Author</label>
    <input type="checkbox" name="bookyear">
        <label for="bookyear">Year</label></form>

    Then I set my 'where' variables in php.

    $bookauthorfield = array(
                 'key' => 'book_author',
                 'value' => pods_var( 'search' ),
                 'compare' => 'LIKE'
    $bookyearfield = array(
                 'key' => 'book_year',
                 'value' => pods_var( 'search' ),
                 'compare' => 'LIKE'

    After this, I used if, else, and isset in an attempt to get the checkbox value and pass it to my $params. If the checkbox is checked, it will search for the field. If not, then it will do nothing.

    if (isset($_GET['bookauthor']))
    	{ $searchbookauthor = $bookauthorfield; }
        { $searchbookauthor = NULL; };
    if (isset($_GET['bookyear']))
    	{ $searchbookyear = $bookyearfield; }
        { $searchbookyear = NULL; };

    Then I changed my $params into

    $params = array(
        'orderby' => 'book_year DESC',
        'limit' => 5,
        'search' => false,
        'where' => array(
             'relation' => 'OR',

    But sadly, that didn't work nor the dozen attempts I made during the past few days. =(
    How do I connect these checkboxes to echo $pod->filters() ?


  2. senyoraangelica
    Posted 1 year ago #

    Okay, okay, I admit it was naive and dumb of me to assume that my checkboxes would somehow magically merge with the form from filters. lol

    How do I add my checkboxes inside echo $pod->filters() ? Is there another way I could echo filters so that I can manually put my checkboxes in?---so that my checkbox values would also get submitted via the search submit button? I would extremely appreciate your advice. =D

  3. senyoraangelica
    Posted 1 year ago #

    Nevermind. I think I figured it out. :)

  4. senyoraangelica
    Posted 1 year ago #

    Just to clarify, is echo $pod->filters() exactly the same as the following code?

    <form action="" method="get" class="pods-form-filters pods-form-filters-books" action>
        <input type="hidden" name="type" value="books">
    	<input type="text" class="pods-form-filters-search" name="search" value="">
        <input type="submit" class="pods-form-filters-submit" value="Search">

    I inserted my checkboxes inside and everything seems to be working fine now but I'd rather not miss anything important that may cause problems in the future.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic