AbanteCart Community
AbanteCart Development => Customization help => Topic started by: snapchris on June 23, 2015, 02:43:50 AM
-
Im trying to add a hidden field that sends the current URL of the page that its on along with the rest of the form data.
Ive tried in form manager but it returns nothing. Any help would be greatly appreciated! Thanks
-
We could use a little more information such as:
Screenshot of the from and the code your using to insert that field.
-
<input type="hidden" name="current_url" value="<?php echo 'http://',$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>" readonly/>
If I add that PHP to the value in Form Manager it send back blank.
(http://s7.postimg.org/7vwuim11n/screen1.png)
-
I think you can not run php code in this way
-
Correct Basara, php can't be used within the form tags.
-
So what I did to get this working is edit hidden.tpl and replace it with this:
<input type="hidden" id="current_url" name="current_url" value="<?php echo 'http:/domainname.com',$_SERVER['REQUEST_URI'];?>" <?php echo $attr ?> />
Then I changed the Field Name & Display Name in the Forms Manager to "current_url" for the Hidden Field Type
You can replace your domain name in place of "domainname.com"
I dont know how this effects anything else with a hidden field, but I only have that one so this works for me.
-
Thank you for posting solution
-
So what I did to get this working is edit hidden.tpl and replace it with this:
<input type="hidden" id="current_url" name="current_url" value="<?php echo 'http:/domainname.com',$_SERVER['REQUEST_URI'];?>" <?php echo $attr ?> />
Then I changed the Field Name & Display Name in the Forms Manager to "current_url" for the Hidden Field Type
You can replace your domain name in place of "domainname.com"
I dont know how this effects anything else with a hidden field, but I only have that one so this works for me.
Good job and well solved, thanks!
-
Thanks! You're Welcome!