We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33238
    • 388 Posts
    Hello, I'm create a form that contains some fields created via MigX, every field contains [[+name]], [[+id]].

    Form:

    <form action="/submit-page.html" method="POST">
    
    <label>First Name <input type="text" name="firstname" /></label>
    
    [[getImageList? 
      &tvname=`myMIGXtv`
      &tpl=`@CODE:<label>[[+name]] <input name="[[+id]]" type="number"></label>
    ]]
    
    <button type="submit">Send</button>
    </form>
    


    Inside the page /submit-page.html there is a snippet to process the form:

    [[!form-processor]]


    The Snippet:

    <?php
    $name = $_POST['name'];
    
    $body = '
    <p>
    Name: '.$name.'<br>
    </p>
    ';


    The question is: How to call the MigxX input list inside the snippet?

    I need something like this but obviously this is not working:

    <?php
    $name = $_POST['name'];
    
    [[getImageList? 
      &tvname=`myMIGXtv`
      &tpl=`@CODE: 
         $[[+id]] = $_POST['[[+name]]'];
    `]]
    
    $body .= '
    <p>Name: '.$name.'</p>
    
    [[getImageList? 
      &tvname=`myMIGXtv`
      &tpl=`@CODE: 
         [[+name]]: '.$[[+id]].'</br>  
    `]]
    
    </p>';
    


    Can somebody guide me please?
    Thanks!

    This question has been answered by Ysanmiguel. See the first response.

      --
      ysanmiguel.com
      • 33238
      • 388 Posts
      Any help please? is this posible? any other recommendation?
      Thanks!!
        --
        ysanmiguel.com
        • 17301
        • 932 Posts
        I would use formit with a hook instead of a dedicated resource for processing a snippet.

        [[!FormIt? &hooks=`form-processor`]]
        
        <form action="[[~[[*id]]]]" method="post">
        	<label>First Name <input type="text" name="firstname" /></label>
        	[[getImageList? 
        	  &tvname=`myMIGXtv`
        	  &tpl=`@CODE:<label>[[+name]] <input name="[[+id]]" type="number"></label>
        	]]
        	<button type="submit">Send</button>
        </form>
        


        Then in the hook you can just grab all values with

        // Get values
        $values = $hook->getValues();
        
        $log = print_r($values, true);
        $this->modx->log(modX::LOG_LEVEL_ERROR, 'Values: ' . $log);
        
        return true;


        I'm not sure what it is you're trying to do with these values though but you can use the all values array in an each statement to potentially to do what you're after? [ed. note: lkfranklin last edited this post 5 years, 4 months ago.]
          ■ email: [email protected] | ■ website: https://alienbuild.uk

          The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • 33238
          • 388 Posts
          LK thanks for your help.

          Mate this is a client's job, somebody build a snippet to get every field from the form manually. Once the user clicks on send, the form validate some fields, then it jumps to another page "Process page" where the snippet will get all the fields data one by one.

          $name = $_POST['name'];


          then print it into a long html, one by one and there are quite a lot:

          $body .= '
          <p>Name: '.$name.'</p>
          ';
          

          So, my job was create the way to give them more freedom, and a system where they can create more fields, so I use MigX, everything good until I need to call everything into this php file.

          The thing is that I don't want to move everything into FormIt, that will take time, it's a long form!.

          The snippet to process the form and the MigX with all the fields are in the same page (The "Processs Page"), is there any way to call all the migX data, give it a html format and print it inside the snippet? should exist isn't?

          Thanks mate!
            --
            ysanmiguel.com
            • 17301
            • 932 Posts
            FormIt would be the more natural choice for forms, and I highly recommend formalicious from modmore also for giving your client control over their forms and adding in additional fields, and field types.

            If you want to stick with migx though you should be able to capture anything posted to the page/snippet with this:

            foreach ($_POST as $key => $value) {
                $this->modx->log(modX::LOG_LEVEL_ERROR, 'Key is: ' . $key . ' Value is: ' . $value);
            }
              ■ email: [email protected] | ■ website: https://alienbuild.uk

              The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
              • 33238
              • 388 Posts
              Quote from: lkfranklin at Dec 20, 2018, 01:40 PM
              FormIt would be the more natural choice for forms, and I highly recommend formalicious from modmore also for giving your client control over their forms and adding in additional fields, and field types.

              If you want to stick with migx though you should be able to capture anything posted to the page/snippet with this:

              foreach ($_POST as $key => $value) {
                  $this->modx->log(modX::LOG_LEVEL_ERROR, 'Key is: ' . $key . ' Value is: ' . $value);
              }

              If the MigX TV is called: myMIGXtv
              how can I call that TV data specifically?

              This is because I got different MigX TV in the same form.
              Thanks! [ed. note: Ysanmiguel last edited this post 5 years, 4 months ago.]
                --
                ysanmiguel.com
                • 17301
                • 932 Posts
                Someone else may be able to suggest something better but you can maybe prefix your migx values with something and then in the hook use stringpos to match the values that have the prefix and then pull them out into something you can use.
                  ■ email: [email protected] | ■ website: https://alienbuild.uk

                  The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                • discuss.answer
                  • 33238
                  • 388 Posts
                  Quote from: lkfranklin at Dec 20, 2018, 04:55 PM
                  Someone else may be able to suggest something better but you can maybe prefix your migx values with something and then in the hook use stringpos to match the values that have the prefix and then pull them out into something you can use.

                  Well mate, at the end I decide move everything to FormIt, so thank you very much for your help.
                  I found a gude in this post from the Jedi Bruno, so that is enough to solve my problem, Thanks mate!.

                  https://forums.modx.com/thread/?thread=83877&page=2
                    --
                    ysanmiguel.com
                    • 17301
                    • 932 Posts
                    Cool, glad you got it sorted smiley
                      ■ email: [email protected] | ■ website: https://alienbuild.uk

                      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                      • 33238
                      • 388 Posts
                      Quote from: lkfranklin at Dec 21, 2018, 08:52 AM
                      Cool, glad you got it sorted smiley
                      Mate, thanks a lot for your time and help, cheers!
                        --
                        ysanmiguel.com