Hi Emanuel,
In this case, it's a two page process...
The first page is solely responsible for generating the initial form. In this case, the Serverside Validation is not evaluated.
The second page is when we process the user input'd data. Here, (apart from the sanity checks), we start off with the Serverside Validation. Depending on the success or failure of the serverside validation, we either move on to file upload, DB storage and sending emails (on success), or re-displaying the form (on failure).
Serverside Validation:
<?
JRequest::setVar('testval', JRequest::getVar('starttime', 'default', 'post'), 'post', true);
if (JRequest::getVar('starttime') != -1)
return JRequest::getVar('starttime');
?>
Form code:
<div>
<label for="starttime">Time of start</label>
<select name="starttime" id="starttime">
<option value="-1" selected></option>
<?
for ($i = 0; $i < 24; $i++)
{
echo(' <option value="' . $i . '">' . $i . ":00</option>\n");
}
?>
</select>
</div>
<input type="submit" /><br />
<? echo JRequest::getString('testval'); ?>
Given the above example, upon first loading the page, the form is displayed as normal. The value of testval is "unset", so the JRequest::getString returns an empty string.
Upon submitting the form, if we keep the default empty value, starttime will be -1, and testval will be set to the same. The validation will succeed, and we'll see an empty "thankyou-page".
If, however, we select any other value, starttime will be set to the very same value, testval will also be set to that value. The form will be redisplayed, and the value of testval (now an integer between 0 and 23) will be printed below the submit button. Tested with CF3.1rc5.3.
Hope this helps explaining the process a little further.
/Fredrik