[TYPO3-project-formidable] How to have hidden fields with a fixed value?
Oliver Klee
typo3-german-01 at oliverklee.de
Wed Jan 10 17:34:34 CET 2007
Hi,
I'm trying to build a semi-two-page form. For this, I use the submit
button of the first page to call a user function which then sets a
variable. My _render function now checks for this variable and then
re-inits the form with a different template (for the second form).
Now I'd like to check whether the *second* form has been submitted. For
this, I'd like to have a hidden variable with a fixed value (that gets
used even when the first form (and thus the complete form) has already
been submitted once). If I understand it correctly, hidden fields take
their value from the POST data if the form has already been submitted,
so I cannot use the default value for the fixed value.
May code looks like this:
[first form]
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<formidable version="0.5.0">
<meta>
...
</meta>
<control>
<datahandler:RAW>
<parentcallback>showConfirmationPage</parentcallback>
</datahandler:RAW>
<renderer:STANDARD>
</renderer:STANDARD>
</control>
...
PHP code:
/**
* Shows the confirmation page.
*
* @param array the entered form data with the field names as array
keys (including the submit button ...)
*
* @access public
*/
function showConfirmationPage($parameters) {
$this->isConfirmationPage = true;
return;
}
/**
* Initializes the create/edit form.
*
* @access protected
*/
function _initForms() {
$this->oForm =& t3lib_div::makeInstance('tx_ameosformidable');
$xmlFile = (!$this->isConfirmationPage) ?
'registration_editor.xml' : 'registration_editor_step2.xml';
$this->oForm->init(
$this,
t3lib_extmgm::extPath($this->extKey).'pi1/'.$xmlFile,
$this->iEdition
);
return;
}
/**
* Creates the HTML output.
*
* @return string HTML of the create/edit form
*
* @access public
*/
function _render() {
$result = $this->oForm->_render();
// For the confirmation page, we need to reload the whole thing.
if ($this->isConfirmationPage) {
$this->_initForms();
$result = $this->oForm->_render();
}
return $result;
}
The second form:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<formidable version="0.5.0">
<meta>
... </meta>
<control>
<datahandler:RAW>
<parentcallback>processRegistration</parentcallback>
</datahandler:RAW>
<renderer:STANDARD>
</renderer:STANDARD>
<actionlets>
<actionlet:REDIRECT>
<url>
<userobj>
<extension>this</extension>
<method>getThankYouAfterRegistrationUrl</method>
</userobj>
</url>
</actionlet:REDIRECT>
</actionlets>
</control>
(and all fields from the first page as hidden fields so that the data is
kept)
I'd like to detect when the second page has been submitted - either with
hidden fields or any other way. How could I do this?
Thanks in advance,
Oliver
More information about the TYPO3-project-formidable
mailing list