• how to capture url parameters into hidden fields of a form#

  • sharadshailly Reply #1, 1 year, 9 months ago

    Reply
    hi,

    I have made an enquiry form in which I kept few hidden fields to capture the url parameters in them. The problem is those url parameters are not getting inserted in the hidden fields

    This is how I did it all:

    I made a snippet A,
    
    <?php
    $modx->setPlaceholder('ememail',$_GET['eme']);
    $modx->setPlaceholder('keyword',$_GET['kw']);
    $modx->setPlaceholder('eventurl',$_GET['url']);
    
    $modx->setPlaceholder('emname',$_GET['emn']);
    $modx->setPlaceholder('emmobile',$_GET['emm']);
    $modx->setPlaceholder('title',$_GET['et']);
    date_default_timezone_set('Asia/Calcutta');
    $enqdate = date('D, d M Y, h:i:s A');
    $modx->setPlaceholder('enqdate',$enqdate);
    $modx->setPlaceholder('redirect',$_GET['redirect']);
    ?>
    
    
    
    


    Then I made an enquiry form chunk with this code in it:
    
    <input type="hidden" name="ememail" size="40"  value="[+ememail+]"  />
    <input name="keyword" size="40" type="hidden" value="[+keyword+]" />
    <input name="eventurl" size="40" type="hidden" value="[+eventurl+]"  />
    <input name="emname" size="40" type="hidden" value="[+emname+]"/>
    <input name="emmobile" size="40" type="hidden" value="[+emmobile+]" />
    <input name="title" size="40" type="hidden" value="[+title+]"/>
    <input name="enqdate" size="40" type="hidden" value="[+enqdate+]"  />
    <input name="redirect" size="40" type="hidden" value="[+redirect+]"  />
    
    
    


    The above code just a part of the enquiry form chunk.
    Please help..
    Thank You!



  • anso Reply #2, 1 year, 9 months ago

    Reply
    Hi
    are you using a get method in your form ? (i.e <form > ) ?

    Cheers


  • sottwell Reply #3, 1 year, 9 months ago

    Reply
    If you are using eForm, the tpl doesn't get processed by MODx; eForm does its own placeholder processing internally.

    You'll need to use a function in your snippet to add the GET values to the $fields array, and use one of eForm's events. Then in the eForm tpl you can use the placeholders.


  • snugg Reply #4, 1 year, 2 months ago

    Reply
    Can you please explain more? I mean is there an example of how to implement this code into a form?

    I also would like to post the keyword in hidden field of a form.

    Thanks in advance.


  • Lucas Reply #5, 1 year, 2 months ago

    Reply
    Here's a nice solution by sharkbait that I've been using successfully. You might need to read through from the beginning to piece together how it works:

    http://modxcms.com/forums/index.php/topic,47130.msg277068.html#msg277068


  • jenban Reply #6, 3 months, 2 weeks ago

    Reply
    Wow, this is the best place I am looking for, many ideas being shared.