Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
85a1d104
Commit
85a1d104
authored
Jun 14, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made some small tweaks to the previous merge
parent
9b7a887e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
doc/providers/form.rst
doc/providers/form.rst
+22
-15
No files found.
doc/providers/form.rst
View file @
85a1d104
...
@@ -7,13 +7,10 @@ your application with the Symfony2 Form component.
...
@@ -7,13 +7,10 @@ your application with the Symfony2 Form component.
Parameters
Parameters
----------
----------
* **form.secret**: This secret value is used for generating and validating the CSRF token
* **form.secret**: This secret value is used for generating and validating the
for a specific page. It is very important for you to set this value to a static randomly
CSRF token for a specific page. It is very important for you to set this
generated value, to prevent hijacking of your forms.
value to a static randomly generated value, to prevent hijacking of your
Defaults to md5(__DIR__).
forms. Defaults to ``md5(__DIR__)``.
* **form.class_path** (optional): Path to where
Symfony2 Form component is located.
Services
Services
--------
--------
...
@@ -22,7 +19,8 @@ Services
...
@@ -22,7 +19,8 @@ Services
<http://api.symfony.com/master/Symfony/Component/Form/FormFactory.html>`_,
<http://api.symfony.com/master/Symfony/Component/Form/FormFactory.html>`_,
that is used for build a form.
that is used for build a form.
* **form.csrf_provider**: An instance of an implementation of the `CsrfProviderInterface
* **form.csrf_provider**: An instance of an implementation of the
`CsrfProviderInterface
<http://api.symfony.com/master/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.html>`_,
<http://api.symfony.com/master/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.html>`_,
defaults to a `DefaultCsrfProvider
defaults to a `DefaultCsrfProvider
<http://api.symfony.com/master/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.html>`_.
<http://api.symfony.com/master/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.html>`_.
...
@@ -30,8 +28,7 @@ Services
...
@@ -30,8 +28,7 @@ Services
Registering
Registering
-----------
-----------
Make sure you place a copy of the Symfony2 Form component in
.. code-block:: php
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
use Silex\Provider\SymfonyBridgesServiceProvider;
use Silex\Provider\SymfonyBridgesServiceProvider;
use Silex\Provider\TranslationServiceProvider;
use Silex\Provider\TranslationServiceProvider;
...
@@ -50,6 +47,17 @@ Make sure you place a copy of the Symfony2 Form component in
...
@@ -50,6 +47,17 @@ Make sure you place a copy of the Symfony2 Form component in
'form.class_path' => __DIR__.'/vendor/symfony/src'
'form.class_path' => __DIR__.'/vendor/symfony/src'
));
));
.. note::
The Symfony Form component does not come with the ``silex`` archives, so
you need to add it as a dependency to your ``composer.json`` file:
.. code-block:: json
"require": {
"symfony/form": "2.1.*"
}
Usage
Usage
-----
-----
...
@@ -61,7 +69,6 @@ example::
...
@@ -61,7 +69,6 @@ example::
})->bind('hello');
})->bind('hello');
$app->match('/', function () use ($app) {
$app->match('/', function () use ($app) {
$validation_constraint = new Collection(array(
$validation_constraint = new Collection(array(
'name' => new NotBlank(),
'name' => new NotBlank(),
));
));
...
@@ -96,11 +103,11 @@ Put this in your template file named ``views/index.twig``:
...
@@ -96,11 +103,11 @@ Put this in your template file named ``views/index.twig``:
<input type="submit" name="submit" />
<input type="submit" name="submit" />
</form>
</form>
You can also add validation to your form by creating a constraint and pass it
as the
You can also add validation to your form by creating a constraint and pass it
`validation_constraint` option::
as the
`validation_constraint` option::
$validation_constraint = new Collection(array(
$validation_constraint = new Collection(array(
'name' => new NotBlank(),
'name' => new NotBlank(),
));
));
$form = $app['form.factory']->createBuilder('form', null, array(
$form = $app['form.factory']->createBuilder('form', null, array(
...
@@ -108,4 +115,4 @@ You can also add validation to your form by creating a constraint and pass it as
...
@@ -108,4 +115,4 @@ You can also add validation to your form by creating a constraint and pass it as
));
));
For more information, consult the `Symfony2 Forms documentation
For more information, consult the `Symfony2 Forms documentation
<http://symfony.com/doc/2.
0
/book/forms.html>`_.
<http://symfony.com/doc/2.
1
/book/forms.html>`_.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment