Commit 9566175f authored by Fabien Potencier's avatar Fabien Potencier

merged branch henrikbjorn/form-httpfoundation (PR #458)

Commits
-------

1981d132 Updated FormServiceProvider documentation to not use the deprecated `bindRequest` method
a12b0cc4 Add HttpFoundationExtension to FormServiceProvider.

Discussion
----------

Add HttpFoundationExtension to FormServiceProvider.

This closes all of the issues with `$form->bind($request)` does not
work issues.

---------------------------------------------------------------------------

by stof at 2012-08-01T22:56:23Z

this fixes #457

---------------------------------------------------------------------------

by thomasjbradley at 2012-08-02T15:45:47Z

I'd love to have this merged soon. I've been recording a bunch of screen casts for my students and this bug is kinda a show-stopper. Thanks!

---------------------------------------------------------------------------

by alexandresalome at 2012-08-02T15:55:27Z

If you're in a hurry:

    cd /path/to/your/project
    cd vendor/silex/silex
    git remote add henrikbjorn https://github.com/henrikbjorn/Silex.git
    git fetch henrikbjorn
    git checkout henrikbjorn/form-httpfoundation

This will do the job temporarly

---------------------------------------------------------------------------

by bradlet at 2012-08-02T15:58:38Z

Thanks so much; I really appreciate it!

---------------------------------------------------------------------------

by bradlet at 2012-08-02T16:16:58Z

I'm a little confused. This update breaks form validation using the constraints array option, like in the Silex docs:

```php
<?php
$form = $app['form.factory']->createBuilder('form')
    ->add('name', 'text', array(
        'constraints' => array(new Assert\NotBlank(), new Assert\MinLength(5))
    ))
```

It throws a `Symfony\Component\OptionsResolver\Exception\InvalidOptionsException`.

Is this something that is no longer allowed within Silex?
Do we need to now make classes like in the Symfony Forms component documentation?
parents 7d2b1f27 1981d132
...@@ -93,7 +93,7 @@ example:: ...@@ -93,7 +93,7 @@ example::
->getForm(); ->getForm();
if ('POST' == $request->getMethod()) { if ('POST' == $request->getMethod()) {
$form->bindRequest($request); $form->bind($request);
if ($form->isValid()) { if ($form->isValid()) {
$data = $form->getData(); $data = $form->getData();
......
...@@ -13,13 +13,14 @@ namespace Silex\Provider; ...@@ -13,13 +13,14 @@ namespace Silex\Provider;
use Silex\Application; use Silex\Application;
use Silex\ServiceProviderInterface; use Silex\ServiceProviderInterface;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension;
use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\ResolvedFormTypeFactory;
/** /**
...@@ -52,6 +53,7 @@ class FormServiceProvider implements ServiceProviderInterface ...@@ -52,6 +53,7 @@ class FormServiceProvider implements ServiceProviderInterface
$extensions = array( $extensions = array(
new CoreExtension(), new CoreExtension(),
new CsrfExtension($app['form.csrf_provider']), new CsrfExtension($app['form.csrf_provider']),
new HttpFoundationExtension(),
); );
if (isset($app['validator'])) { if (isset($app['validator'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment