forms unleashed
Objective: Insert a $_GET parameter value dynamically into a TypoScript form.
Let's say you want to give your visitors the possibility to send a feedback to some pages (same as we did below in the "Did this document help you"-box). For realizing this completely in TypoScript 2 steps are to consider:
![]() | Step 1: Creating some lines in TypoScript which create an appropriate link. In this case a link with appended parameters which will need in the form later. |
![]() | Step 2: Modifying the content.default form in a way that our parameters can be inserted. |
step 1: creating a TYPOLINK
- # we create a TEXT object named "feedback"
- feedback = TEXT
- # we add a string/value which will be the linked text
- feedback.value = give me some feedback to this page
- # set the link to a specific page ID where the form will reside (in this example PID 33)
- feedback.typolink.parameter = 33
- # of course we need additional parameters to the link
- # we pass the $_GET variable value (which has the value "somevalue")
- feedback.typolink.additionalParams =&value=somevalue
Now we have an object which will create a link like this one (of course you have to put it into a page object to make it appear on the page):
<a href="index.php?id=33&value=somevalue">give me some feedback to this page</a>
Now we are ready for
step 2: creating the form
Go to page 33 (in our example) and create a standard form content element.
![]() |
- # we define a form object
- response.form = FORM
- # now we import the standard mailfrom from the styles.content class
- response.form < styles.content.mailform
- # we override some values (those are not essential for our purpose)
- response.form {
- layout = ###LABEL### ###FIELD###<br />
- labelWrap.wrap =|
- fieldWrap.wrap = |<br />
- commentWrap.wrap = |
- radioWrap.wrap = |
- stdWrap.wrap= |
- # This is the interesting part:
- # We create a COA object which is applied to the stdWrap. This means, that
- # it will be shown BEFORE the form, so we can use it as headline
- stdWrap.innerWrap.cObject = COA
- stdWrap.innerWrap.cObject {
- 10 = TEXT
- # We apply our variable (you remember that we named it "value" above)
- # and make it being inserted via insertData.
- # Without insertData {GPvar:value} would be interpreted only as string.
- 10.value = <h2>The parameter value is "{GPvar:value}"</h2>
- 10.insertData=1
- }
- # until this point we have inserted some values, but they are not in the form, yet.
- # So we add our data to the form by the dataArray.
- # Finally we need it as hidden form element:
- dataArray {
- 999.type=value=hidden
- 999.value= Value passed by $_GET: {GPvar:value}
- 999.value.insertData=1
- }
- }
- # Now this is important too: We need to re-import our mailform back into the
- # content.default class. The reason is that this class is normally being processed
- # earlier, therefore we have to reimport it to make our changes to the default class work
- tt_content.mailform.20 < response.form
Voila. Now the $_GET variable will be sent with the form and will appear in the mail, too.


