Handling errors
Errors could occur during the form processing. When an error occur, LemonStand places its message to the internal variable. You canuse the flash_message function to display error messages. Usually you place the flash_message function call above forms.
The following example demonstrates the Change Password page.
<h2>Change Password</h2> <?= open_form() ?> <?= flash_message() ?> <label for="old_password">Old Password</label> <input id="old_password" type="password" name="old_password"/><br/> <label for="password">New Password</label> <input id="password" type="password" name="password"/><br/> <label for="password_confirm">Password Confirmation</label> <input id="password_confirm" type="password" name="password_confirm"/><br/> <input type="submit" name="change_password" value="Submit"/> <input type="hidden" name="redirect" value="/password_change_success"/> </form>
If you process forms in AJAX mode, you do not need to use the flash_message function, because AJAX errors are displayed using the popup messages (JavaScript alert messages).
See also:
Next: Page Not Found (404) page
Previous: Programming Pages
Return to Creating Pages
Comments
No comments posted so far.
Add your comment
Loading form...