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
    Try casting the fields to (int) before saving them.

    $process->set('request',(int) $request->get('id'));
    $process->set('customer', (int) $request->get('customer'));
      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
      • 30585
      • 833 Posts
      @BobRay, thanks for the hint. I tried this:
      if (isset($_POST['submit'])) {
          // Form has been submitted 
          $process = $modx->newObject('quoteProcess');
          //$process->fromArray($process_fields);
          $process->set('request',(int) $request->get('id'));
          $process->set('customer', (int) $request->get('customer'));
          if ($process->save()) {
      ...
      }

      Still getting 1 in those two fields when the form is processed. I'm lost.
        A MODx Fanatic
        • 3749
        • 24,544 Posts
        Are you still doing the addOne() on those two fields? It should be unnecessary and could be interfering with the procedure.

        The next step would be to see if the $request fields are set properly with something like this:

        $output = '<p>ID: ' . $request->get('id') . '</p>';
        $output .= '<p>CUSTOMER: ' . $request->get('customer') . '</p>';
        die($output);


        BTW, you haven't overridden the set() method in your class have you?
          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
          • 30585
          • 833 Posts
          Hey BobRay, I think i know what the problem is. The submission ID retrieved via $_GET() is parsed as a string, but the customer and request fields are integer. When I manually entered the submission ID in the snippet, the values where saved properly. So now I need to convert the submissionID into an integer before saving. I hope this fixes it.

          I'll report back.

          [ed. note: treigh last edited this post 9 years, 4 months ago.]
            A MODx Fanatic
          • discuss.answer
            • 30585
            • 833 Posts
            @Bruno17, @BobRay thanks again for all your help. i've found a workaround!

            I'm using hidden fields in the form to pass the requestid and customerid values to the snippet.
              <input type="hidden" name="customerid" value="[[+customer]]"> 
              <input type="hidden" name="requestid" value="[[+id]]">

            Then in the snippet:
            $process_fields = array(
                'request' => $_POST['requestid'],
                'customer' => $_POST['customerid'],
               ...
            );
            

            This does it for me. $process->save() is saving the right values into those fields. I wish I knew why I couldn't get this done with $request->get('id') and $request->get('customer'), but I can live with the fix.
              A MODx Fanatic
              • 4172
              • 5,888 Posts
              be aware, that the user could manipulate the hidden-fields!
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 30585
                • 833 Posts
                You're right. Luckily this form will be used internally by the front desk, behind a login page.
                  A MODx Fanatic