We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I think I know what's wrong. I was assuming that you were using the actual DB field names for the names of the fields in the form (because -- why not?).

    You could change them in the form and in the $options array to match the db field names, but if you need them to be different, The $options array would be:

    $options array(
       'nameused in $_POST' => 'nameused in DB',
       //etc.
    );


    And the foreach code would be:

    $search = array();
    foreach ($options as $postName => $dbName) {
       $val = $modx->getOption($postName, $_POST, '');
       if (!empty($val)) {
           $search[$dbName] = '1';
       }
    }


    Another possible issue:

    What is the actual value of the field in the database when the user has the value? I assume 1 vs. 0, but if it's 'x' that could be the problem.


      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 38783
      • 571 Posts
      Hello Bob

      The DB field names are, as you assume, the same as those in the form (profileTwo, profileThree etc). The labels are different - at present I don't know what the final data will be hence the generic sounding names.

      The value in the DB if the trainer provides the service is '1', if they do not provide the service it is '0'.

      In the form, if the box is not ticked, a value of x was being returned, but I have changed this to be blank.

      Thanks for the Trivia follow up. Google had only led me to the most commonly used letter answer, not the literary one.

      Unfortunately I think these answers of mine mean that your original assumptions were correct and that my problem lies elsewhere?
        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

        email: [email protected] | website: https://andytough.com
        • 3749
        • 24,544 Posts
        Unfortunately I think these answers of mine mean that your original assumptions were correct and that my problem lies elsewhere?

        I'm afraid you might be right. Is there anything useful in the the MODX Error Log?
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 38783
          • 571 Posts
          Hello Bob

          There is nothing in the error log.

          However I think the php is generating an array that includes user_search_ in the field name. So it becomes user_search_profileTwo not profileTwo.

          So I may need to use your new code to rename it after all.

          I will investigate this as soon as I get a chance. Thank you for your help so far.

          Best wishes

          Andy
            If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

            email: [email protected] | website: https://andytough.com
            • 3749
            • 24,544 Posts
            I noticed that your original code above does this:

            $pprofileTwo = $modx->getOption('user_search_profileTwo', $_POST, '');


            That would only work if the field in the form has: name="user_search_profileTwo".
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting