Example: How to use custom validator
- 1: <?php
- 3: /**
- 4: * Nette\Forms example 5
- 5: *
- 6: * - custom validator usage
- 7: */
- 18: // Step 0: Define custom validator
- 20: {
- 22: }
- 26: // Step 1: Define form with validation rules
- 40: // Step 2: Check if form was submitted?
- 43: // Step 2c: Check if form is valid
- 50: // this is the end, my friend :-)
- 52: }
- 55: // not submitted, define default values
- 62: }
- 66: // Step 3: Render form
- 67: ?>
- 68: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- 69: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- 70: <head>
- 71: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- 72: <meta http-equiv="content-language" content="en" />
- 74: <title>Nette\Forms example 5 | Nette Framework</title>
- 76: <style type="text/css">
- 77: <!--
- 78: .required {
- 79: color: darkred
- 80: }
- 82: fieldset {
- 83: padding: .5em;
- 84: margin: .3em 0;
- 85: background: #EAF3FA;
- 86: border: 1px solid #b2d1eb;
- 87: }
- 89: input.button {
- 90: font-size: 120%;
- 91: }
- 93: th {
- 94: width: 8em;
- 95: text-align: right;
- 96: }
- 97: -->
- 98: </style>
- 99: </head>
- 101: <body>
- 102: <h1>Nette\Forms example 5</h1>
- 105: </body>
- 106: </html>