Skip to content

Commit 36ee64c

Browse files
committed
added readme.md
1 parent 7b661be commit 36ee64c

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

readme.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Nette Forms: greatly facilitates web forms
2+
==========================================
3+
4+
Nette\Forms greatly facilitates creating and processing web forms. What it can really do?
5+
6+
- validate sent data both client-side (JavaScript) and server-side
7+
- provide high level of security
8+
- multiple render modes
9+
- translations, i18n
10+
11+
Why should you bother setting up framework for a simple web form? You won't have to take care about routine tasks such as writing two validation scripts (client and server) and your code will be safe against security breaches.
12+
13+
Nette Framework puts a great effort to be safe and since forms are the most common user input, Nette forms are as good as impenetrable. All is maintained dynamically and transparently, nothing has to be set manually. Well known vulnerabilities such as Cross Site Scripting (XSS) and Cross-Site Request Forgery (CSRF) are filtered, as well as special control characters. All inputs are checked for UTF-8 validity. Every multiple-choice, select boxe and similar are checked for forged values upon validating. Sounds good? Let's try it out.
14+
15+
[See documentation](http://doc.nette.org/en/forms).
16+
17+
First form
18+
----------
19+
20+
Let's create a simple registration form:
21+
22+
```php
23+
use Nette\Forms\Form;
24+
25+
$form = new Form;
26+
27+
$form->addText('name', 'Name:');
28+
$form->addPassword('password', 'Password:');
29+
$form->addSubmit('send', 'Register');
30+
31+
echo $form; // renders the form
32+
```
33+
Though we mentioned validation, yet our form has none. Let's fix it. We require users to tell us their name, so we should call a `setRequired()` method, which optional argument is an error message to show, if user does not fill his name in:
34+
35+
```php
36+
$form->addText('name', 'Name:')
37+
->setRequired('Please fill your name.');
38+
```
39+
40+
Try submitting a form without the name - you will se this very message until you meet the validation rules. All that is left for us is setting up JavaScript rules. Luckily it's an piece of cake. We only have to link `netteForms.js`, which is located at `/client-side/forms` in the distribution package.
41+
42+
```html
43+
<script src="netteForms.js"></script>
44+
```
45+
46+
Nette Framework adds `required` class to all mandatory elements. Adding the following style will turn label of *name* input to red.
47+
48+
```html
49+
<style>
50+
.required label { color: maroon }
51+
</style>
52+
```
53+
54+
[Continue…](http://doc.nette.org/en/forms).
55+
56+
-----
57+
58+
[![Build Status](https://secure.travis-ci.org/nette/forms.png?branch=master)](http://travis-ci.org/nette/forms)

0 commit comments

Comments
 (0)