Answered

Passing PHP variable as hidden field value

  • 13 April 2022
  • 3 replies
  • 1073 views

Userlevel 2
Badge

Hello all, I am trying to pass a php variable as a value of hidden field.

Here is what I have: data-tf-hidden="case_id=<?php $CaseGUID ?>"

$CaseGUID is set to the GUID which is in the page url.

The idea is to capture the GUID to be saved with the form submission, so I can map it to a record in a SQL Server table.

The GUID is in the url as : ?case=9576A93E-E644-4D5B-971A-E99CC061D542

So I have also tried it this way: data-tf-hidden="case_id=case" and what gets passed to the hidden field is the word “case”, and not the GUID  value in the url.

 

I am not sure what I’m doing wrong, but nothing seems to work.

 

icon

Best answer by mathio 13 April 2022, 11:38

View original

3 replies

Userlevel 7
Badge +5

Hello @Silvio Ribeiro 

if you use code data-tf-hidden="case_id=case" then it will pass string “case” to your hidden field.

In PHP you should use a variable and print it out like this: 

data-tf-hidden="case_id=<?= $CaseGUID ?>"

Note the <?= tag, see #2 in PHP docs on PHP tags.

Userlevel 2
Badge

Thank you @mathio, you are awesome!

That worked perfectly.

Userlevel 7
Badge +5

Amazing, @Silvio Ribeiro! Don't forget to share your form and your use case with us! We'd love to take a look at it and give you some feedback! 😉
 

 

Reply