This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Enable Code in Admin Only Fields?
Started 16 years ago by epsd | 15 posts |
-
Just installed under SSL and what a relief it is to have a program like this! Anyway, I have some variables that are being passed from page to page in sessions. I modded the app so that it sees this session data. Works fine. Now, I'd like to get that session data (just a username for example) into an admin only field. In hand coded forms, I'd simply do a php echo of the variable in the value.
However, machforms just displays the code and not the variable. I realize that this is for security purposes. Is there a way that I can turn off some of this security for the admin only fields? I'm running in a secure environment so I'm not too concerned about it...
Posted 16 years ago # -
Hmm..I'm afraid it won't be as simple as turning off a feature.
You will need to modify the specific function which display the fields.
All of them are placed in includes/view-functions.phpOk, let say we have a form with form_id = 12 and a 'Single Line Text' field which is set to 'admin only' and has element name element_3.
To get your session variable into that field. Edit display_text() function. Around line 29 you will find this code:
//check for populated value, if exist, use it instead default_value if(!empty($element->populated_value['element_'.$element->id]['default_value'])){ $element->default_value = $element->populated_value['element_'.$element->id]['default_value']; }
Right under that block of code, add this code:if(($_REQUEST['id'] == 12) && ($element->id == 3)){ $element->default_value = $_SESSION['your_session_var']; }
That should set the default value for that particular 'admin only' field to be the same as your session variable.I hope I'm being clear for you.
Please feel free to ask any question you might have.MachForm Founder
Posted 16 years ago # -
sounds easy enough. how do I determine the element name? Is it just what I've named it or is it from my database? Thanks for your help!!
Posted 16 years ago # -
Simply right click on your form and view source.
The element name would be the actual HTML element name.MachForm Founder
Posted 16 years ago # -
I'm using the code in regular fields and it now works fine, however, it doesn't work in admin only fields... I have installed the updated bug-fix for admin only fields (which has fixed most of the bug, except for the above for some reason).
Posted 16 years ago # -
Hmm..what doesn't work? The 'admin only' field shows blank value?
It seems tricky to continue in the forum.Could you please mail me the following:
- includes/view-functions.php file
- your machform URL
- your machform username + passwordSend them to yuniar [at] appnitro.com
I'll take a look.MachForm Founder
Posted 16 years ago # -
Sorry, I was out for the weekend...The field contains the value (i.e., I can see it on-screen), but it doesn't get posted to the database (or sent in an email) when the field is set to admin only. It works fine (i.e., is sent to the DB) when the field is set as 'everyone'.
I can't give you the URL as it is on a secured intranet... I can send you the view-functions.php file if you'd like.
Posted 16 years ago # -
Hmm..that's weird, if the field contains the value already, it should be posted to the database. Can you send me the HTML code of this form?
Send me your view-functions.php file too, or any other modified files.
MachForm Founder
Posted 16 years ago # -
I'll send it first thing in the morning. It does send the value when the field is set to 'view by everyone' just not when admin only.
Posted 16 years ago # -
ok got it. I've replied back.
MachForm Founder
Posted 16 years ago # -
OK, I followed the steps above. I have a hidden field(element_06) in form 13. Here is the code I'm using in view-functions.php:
//check for populated value, if exist, use it instead default_value
if(isset($element->populated_value['element_'.$element->id]['default_value'])){
$element->default_value = $element->populated_value['element_'.$element->id]['default_value'];
}
if(($_REQUEST['id'] == 13) && ($element->id == 6)){
$element->default_value = $_SESSION['form_data']['element_1'];
}As you can see I'm trying to pre-populate element_06 from a session variable set from the previous form (element_01), but it's not working for me
I know the session is working... I checked it using <?php print_r($_SESSION['form_data']); ?>.
Posted 15 years ago # -
Is element_6 an admin-only field?
If so, you need to be logged in to your machform admin panel first.
MachForm Founder
Posted 15 years ago # -
No, I hid the field using CSS using display:none;.
Posted 15 years ago # -
Hmm... can you send me the two URL to your forms?
Also send me your view-functions.php fileI'll check and test it.
Please mail to: customer.service [at] appnitro.comMachForm Founder
Posted 15 years ago # -
OK, sent. Thanks!
Posted 15 years ago #
Reply
You must log in to post.