RackForms v7.8.8
hidden field
Site Tag Line
Latest Release: Build 958 - Arpil 18th, 2023
Contact Us  Purchase Options Purchase Options Contact Us
header-image


 
Top Link
Text Hidden

In Brief: Field for storing value which is not displayed to the end-user.

Dependencies: none.

Hints & Tricks: none at the moment.

Options/Properties

Basic Attributes

Label

This field is what determins the Label our entires will have in the RackForms entry viewer. In Builder lower than 672, this was the value of the hidden field.

Using PHP Code For The Default Value

You can type dynamic php in the Default Value block and it will execute at form runtime. For example, you could run:

<?php echo rand(1, 100); ?>

To set the value of the hidden field to a random number between 1 and 100.

<?php echo date('Y/m/d', time()); ?>

Would create a date timestamp in the format of: 2010/09/28.

This process does not include the use of $_SESSION fields! To use $_SESSION variables in your hidden field you will first need to assign the $_SESSION variable to a local PHP variable with something like this in the Page PHP Top Code area:

session_start();
$sample = $_SESSION['sample'];

You could make the value of the hidden field equal the session variable value with:

<?php echo $sample; ?>

IMPORTANT NOTE OF USING $_SESSION VARIABLES

One thing to keep in mind--if you use $_SESSION variables like this please be sure to use:

unset($_SESSION['variable_name']);

In the Page PHP Footer Template Code part of your confirmation page or the variable will persist and possibly cause strange behavior!

You could also set other variables in the Page PHP Head Code field and display the value using the same technique. As an example, a reservation system might use PHP head code to query a database table for a reservation number, you would them echo that reservation number in this hidden field.

To generate a random number for the form submission, a timestamp, and so on.

Note for hidden values and the Simple SQL Module and the RackForms Entry Viewer

As the Simple SQL module uses the Label attribute of your field items to create the Entry Viewers column header, you will notice the displayed column name for that value will be the label attribute you place in this box. In most cases this produces the expected output, as your label in the form is the column head in the entry viewer. For example, Name for a text field in the form would be Name in the entry viewer.

Name/Value

This element is set by RackForms automatically, though it is recommended to change this value if you decide to display Javascript validation messages, as the text of the error is the value of this field. This value is displayed by default if no Label attribute is assigned to the element. For technical users, this element name is in fact the same as the Name/Value html form attribute of this element.

id

By default is assigned the same value as the Name/Value element, though you can change this to a more field specific value. Not necessary for most applications. For technical users, this is the id attribute of the field item.

Default Value

We use this field to set the value of the hidden field item..

So for example, if you use a Default Value of 'tester', our HTML would look like:

<input type="hidden" name="hidden0" id="hidden0" value="tester" />

Using RackForms 2 Tokens

We can use RackForms 2 tokens in the Default Value field which means we can use:

F{field} = FIELD Elements (e.g. Form Items)
S{session} = SESSION
P{post} = POST
G{get} = GET
${php} = PHP

To access the named variable types. Please note the code is meant to output simple text values, not complex expressions. A typical example of code RackForms creates for a GET variable (G{}) is:

<?php if(isset($_GET['id'])) { echo $_GET['id']; } ?>




So many features, So little time