Example: Form definition using fluent interfaces
- 1: <?php
- 3: /**
- 4: * Nette\Forms basic example.
- 5: *
- 6: * - form definition using fluent interfaces
- 7: * - form groups usage
- 8: * - default rendering
- 9: */
- 38: // Step 1: Define form with validation rules
- 41: // group Personal data
- 43: ->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
- 61: // group Shipping address
- 70: // subgroup
- 86: // group Your account
- 107: // group for buttons
- 114: // Step 2: Check if form was submitted?
- 117: // Step 2c: Check if form is valid
- 124: // this is the end, my friend :-)
- 126: }
- 129: // not submitted, define default values
- 137: }
- 141: // Step 3: Render form
- 142: ?>
- 143: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- 144: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- 145: <head>
- 146: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- 147: <meta http-equiv="content-language" content="en" />
- 149: <title>Nette\Forms basic example | Nette Framework</title>
- 151: <style type="text/css">
- 152: <!--
- 153: .required {
- 154: color: darkred
- 155: }
- 157: fieldset {
- 158: padding: .5em;
- 159: margin: .3em 0;
- 160: background: #EAF3FA;
- 161: border: 1px solid #b2d1eb;
- 162: }
- 164: input.button {
- 165: font-size: 120%;
- 166: }
- 168: th {
- 169: width: 8em;
- 170: text-align: right;
- 171: }
- 172: -->
- 173: </style>
- 174: </head>
- 176: <body>
- 177: <h1>Nette\Forms basic example</h1>
- 180: </body>
- 181: </html>