Adding a hidden component

This component is useful when we wish to have data stored in the database that the site visitor did not explicitly enter.

How to do it...

Let's see how we can add an invisible component to our form.

  1. Add a new Hidden component named Browser Type and click on the Add button.
  2. Under Default value we enter the super token %server[HTTP_USER_AGENT] and click on Save component.
  3. We leave CONDITIONAL RULES as they are to ensure that this component always receives a value.
How to do it...

How it works...

Hidden fields are not truly hidden in the fullest sense of the word, they are merely hidden from view as far as the form user is concerned. The field is included in the generated HTML, but the web browser will simply not display the field on the web page.

The super token that we entered (which only applies to visitors who are currently logged in on our site) will populate this field with information that can give us hints as to the operating system of the visitor's computer and which web browser they used to visit our site.

There's more...

While hidden fields may be used for any purpose we require, the example we have worked through previously contains a caveat we should be aware of.

Browser detection

In the early days of the Internet, there was an ongoing battle for supremacy in terms of web browsers. Microsoft Internet Explorer and Netscape Navigator were two of the most popular browsers at the time, each with its own hardcore fan base. By making use of browser detection via the testing of the HTTP_USER_AGENT variable, proponents of the two sides would either limit, alter, or in extreme cases, even flatly deny content if we happened across their website with the wrong browser.

Thankfully those days are behind us now and more cooperative spirit abounds. We should not be entirely surprised, however, to discover that many versions of Internet Explorer still masquerade themselves as being Mozilla browsers.

As with the IP Address stored in submission metadata, we should not be over-reliant on this information as it is fairly easy to spoof. That being said, it is still common enough for some level of browser detection to occur, but this centers mainly around determining the ability of the browser to properly render the page content.

There are web pages with content that cannot be normally displayed on Internet Explorer 6, for example, and web developers will use browser sniffing to determine the content that their applications should output. In Drupal, the bulk of this kind of thing normally gets handled in the CSS files.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset