Example: Form definition using fluent interfaces
- 1: <?php
- 3: /**
- 4: * Nette\Forms example 2
- 5: *
- 6: * - form definition using fluent interfaces
- 7: * - form groups usage
- 8: * - default rendering
- 9: */
- 52: // Step 1: Define form with validation rules
- 55: // group Personal data
- 57: ->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
- 75: // group Shipping address
- 84: // subgroup
- 100: // group Your account
- 121: // group for buttons
- 128: // Step 2: Check if form was submitted?
- 131: // Step 2c: Check if form is valid
- 138: // this is the end, my friend :-)
- 140: }
- 143: // not submitted, define default values
- 151: }
- 155: // Step 3: Render form
- 156: ?>
- 157: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- 158: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- 159: <head>
- 160: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- 161: <meta http-equiv="content-language" content="en" />
- 163: <title>Nette\Forms example 2 | Nette Framework</title>
- 165: <style type="text/css">
- 166: <!--
- 167: .required {
- 168: color: darkred
- 169: }
- 171: fieldset {
- 172: padding: .5em;
- 173: margin: .3em 0;
- 174: background: #EAF3FA;
- 175: border: 1px solid #b2d1eb;
- 176: }
- 178: input.button {
- 179: font-size: 120%;
- 180: }
- 182: th {
- 183: width: 8em;
- 184: text-align: right;
- 185: }
- 186: -->
- 187: </style>
- 188: </head>
- 190: <body>
- 191: <h1>Nette\Forms example 2</h1>
- 194: </body>
- 195: </html>