Search Form Problems

16 posts by 3 authors in: Forums > CMS Builder
Last Post: March 16, 2016   (RSS)

By northernpenguin - March 15, 2016

I am having 2 problems with a search form I just created.  There are 2 search fields, and the user can choose either or both. I am using the Bootstrap 3 framework. Here are the 2 problems:

a.  the search displays all the records and ignores the search parameters; and

b.  the second field is a dropdown list from another table.  It will not display.

Here is the code

<?php include 'common/includes/php_header.inc'; ?>
<?php
  // load records from 'mite_course_id'
  list($mite_course_idRecords, $mite_course_idMetaData) = getRecords(array(
    'tableName'   => 'mite_course_id',
    'loadUploads' => true,
    'allowSearch' => true,
  ));
?>

The form code

<form action="searchResults.php" method="post">
   <div class="form-group">
     <label for="QSPtitle">QSP Title</label>
     <input type="text" class="form-control" id="QSPtitle" placeholder="Words in a QSP Title">
   </div>
<div class="form-group">
   <label for="courseID">Course ID:</label>
   <select class="form-control" id="courseID">
   <option value="">Please choose a Course ID</option>
         <?php foreach (getListOptions('mite_course_id','course_id') as $value => $label): ?>
<option value="<?php echo $value; ?>" <?php selectedIf($value, @$_REQUEST['course_id']); ?>>
<?php echo $label; ?>
  </option>
    <?php endforeach ?>  
</select>
</div>
   <button type="submit" class="btn btn-default">Submit</button>
</form> 

Any help would be greatly appreciated!

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By Damon - March 16, 2016

Hi,

Here are some notes to hopefully help.

1. For the select, add in the name:

 <select class="form-control" id="courseID" name="courseID">

2. While testing, change the form method to get so you can see what search query values are being passed in the URL.

<form action="searchResults.php" method="get">

3. Check that the course_id field in the mite_course_id Section Editor is a list field type.

4. Try adding this stripped down code to see if this outputs the all the list field list options:

<?php foreach (getListOptions('mite_course_id','course_id') as $value => $label): ?>
   <?php echo $value;?> - <?php echo $label;?><br />
<?php endforeach ?>

Let me know if this shows the expected results. Also, can you post a link to your test page for me to look at here or email to support@interactivetools.com

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Damon - March 16, 2016

Hi Maurice,

If the 3 dropdowns fields to populate are each based on different list fields in CMS Builder, you can use the same code block for each but modified as needed and with the section editor name and field name added. Example:

//select drop down
<select name = "myListField">
<?php foreach (getListOptions('mySection', 'myListField') as $value => $label): ?>
<option value = "<?php echo $value;?>"><?php echo $label;?></option>
<?php endforeach ?>

Just repeat and modify for each. 

Here is the list of other Search Field Formats:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

And, as always, we are here to answer any other specific setup questions you have.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By northernpenguin - March 16, 2016 - edited: March 16, 2016

Damon:  I made all your suggested changes, but the list still does not display.  Here is the page on my current sandbox (its a Google Cloud server)

http://www.legassie.net/index.php   -  choose the "Search database" menu item.

P.S.  I just noticed that eh "Submit" button is no longer display??

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By Damon - March 16, 2016

Hi,

This error, that appears in the page source code, usually means that the field type reference in the code isn't a list field type.

<!-- Unknown optionsType ''!

Can you send in the CMS Builder login and FTP details so I can take a closer look:
https://www.interactivetools.com/support/email_support_form.php?priority=free&order=Forum%20Support

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By northernpenguin - March 16, 2016 - edited: March 16, 2016

Access to CMSB is not an issue, unfortunately with a Google Cloud server (Trial) running Ubuntu all I have is SSH access.  I will send you the file itself instead.

search.php attached.

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Attachments:

search.php 5K

By Damon - March 16, 2016

Ok thanks.

Can you also send in a Support Request with CMS Builder login details so I can take a look at the setup and check the code?

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By northernpenguin - March 16, 2016

I did with the link provide in your previous post

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By Damon - March 16, 2016

OK thanks. I see it now.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/