Front end search form issues

12 posts by 2 authors in: Forums > CMS Builder
Last Post: January 8, 2016   (RSS)

By ross - January 5, 2016

Hi Jerry

Thanks for posting.  Let's focus on the LIST FIELDS issue first.

It sounds to me like you want someone to be able to select more than one option from your "Levels Of Care" drop down.  There are two things to adjust for this. First is to add "multiple" to the <select> tag and then change the name modifier from "_match" to "_keyword" like this:

<select name = "levels_of_care_keyword" width="300" class="text_font" style="width: 300px" multiple >

Try that and see how it effects your output.

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By gkornbluth - January 6, 2016 - edited: January 6, 2016

Hi Ross,

Thanks for your suggestion.

The multiple entry issues seem to be sorted out.

Here's the final code:

<tr>
        <td  align="right" class="text_font"><b>Levels of Care Required:</b><br />Select all applicable</td>
         <td align="left" valign="bottom" colspan="2"><select name = "levels_of_care_keyword"  width="300" class="text_font" style="width: 300px; max-height: 50px;"  multiple>
          
            <?php foreach (getListOptions('accounts', 'levels_of_care') as $value => $label2): ?>
            <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['levels_of_care']);?>> <?php echo $label2; ?></option>
            <?php endforeach ?>
          </select></td>
      </tr>

I changed the telltale code from match to keyword as well, but the telltale now shows only the last entry in the selected keywords (still with the option value (record number) instead of the option label).

Here's the current telltale code:

 if (@$_REQUEST['levels_of_care_keyword']) { $searchCriteria .= "<b>Levels of Care:</b> {$_REQUEST['levels_of_care_keyword']} - "; }

Hope this is as easy a fix.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By ross - January 6, 2016

Hi Jerry

What you need is something like this:

$levels_of_care_values =  implode(',', $_REQUEST['levels_of_care_keyword']);

That will give you a comma separated list of all the options selected on the previous page.

Let me know if that works for you.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By gkornbluth - January 6, 2016

Hi Ross,

Thanks as always,

I'm assuming that you meant the code to be incorporated into the telltale code below, and I mucked about a bit, but can't seem to figure out exactly how to accomplish that.

 if (@$_REQUEST['levels_of_care_keyword']) { $searchCriteria .= "<b>Levels of Care:</b> {$_REQUEST['levels_of_care_keyword']} - "; }

Best,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By ross - January 6, 2016

Hi Jerry

This is what I think you are looking for:

if (@$_REQUEST['levels_of_care_keyword']) {
    $levels_of_care =  implode(',', @$_REQUEST['levels_of_care_keyword']);
    $searchCriteria .= "<b>Levels of Care:</b> $levels_of_care - ";
}

Let me know if that works for you.

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By gkornbluth - January 6, 2016 - edited: January 6, 2016

Hi Ross,

Thanks for clarifying

Unfortunately, when I try to implement the new code, I get the following error:

Warning: implode(): Invalid arguments passed in /home7/ellescho/public_html/dbtct/directory_results.php on line 124

I can make the error go away by adding $_REQUEST['levels_of_care_keyword'] = array(); in front of your implode code as suggested in a post on stackoverflow.com,

 if (@$_REQUEST['levels_of_care_keyword']) {
      $_REQUEST['levels_of_care_keyword'] = array();
    $levels_of_care =  implode(',', @$_REQUEST['levels_of_care_keyword']);
    $searchCriteria .= "<b>Levels of Care:</b> $levels_of_care - ";
    
 }

but then the $levels_of_care variable does not seem to contain any values at all.

Thanks

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By ross - January 7, 2016

Hi Jerry

My first thought on the error you got is that nothing was selected in the multi select field when you submitted the form.  You can add some extra error checking to make sure the "impode" function doesn't execute if  "levels_of_care_keyword " is empty. 

I'm attaching a simple test script I based my last post on. 

That will show you want I am doing and will hopefully get you on the right track.  The script will run from anywhere on your server and doesn't need CMS Builder.

Let me know any questions or feedback.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Attachments:

multiSearchTest.php 1K

By gkornbluth - January 7, 2016

Hi Ross,

Thanks yet again...

I tried adding the extra error checking by including  a check for a hidden field  in the form <input type="hidden" name="save" value="1" />

if (($_REQUEST['save'] == 1) && @$_REQUEST['levels_of_care_keyword']) {
   //  $_REQUEST['levels_of_care_keyword'] = array();
    $levels_of_care =  implode(',', @$_REQUEST['levels_of_care_keyword']);
    $searchCriteria .= "<b>Levels of Care:</b> $levels_of_care - ";
    
 }

But I still have the same issue.(although your test form does work)

I hate to keep asking you to work on this without compensation, so if you feel you want to convert this to a small consulting, that would be OK.

The telltale is supposed to show the result of the multi search as a reminder of what criteria were selected, and since the search fields are populated from a separate database I need the option label to be shown in the telltale instead of the option value (record number) which shows now.

I've attached both the directory search and the directory results pages

You can see the telltale code in question in the directory_results page beginning on line 120

I didn't want to update any of the other code until I got this one working

Best,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By ross - January 8, 2016

Hi Jerry

Aside from the fact my example only uses one page and yours splits across two, does my test script simulate the functionality you are aiming for?

Basically, what I am assuming is you have a form submit with a multi-select field and output the values selected in that field. Among other things of course.

If I'm on the right track here, what you'll want to do is simply your pages to the point where it just does this one thing. The first page has a multi-select field on it and the second page displays the values selected.  Then you can start adding back in the rest of your code that was already working.

Does that make sense?

With the consulting, that would only kick in if I am actually doing the coding myself.  We can keep this in the forum if you want to keep working on the code yourself. 

We can keep this in the forum if you want to keep working on the code yourself. Consulting would only kick in if I am actually doing the coding myself.

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/