[Form] Added valid attribute to a FormView
Modified example for mod_rewrite to not add Authorization header if it is not set in the request
merged branch kevindew/form_view_errors (PR #4224)

Commits
-------

e92212a [Form] Added valid attribute to a FormView

Discussion
----------

[Form] Added "valid" to view parameters

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets:
Todo:
License of the code: MIT
Documentation PR:

This PR adds a parameter of contains_errors to a FormView when buildView is called.

The use case for this addition is when you want to show that a form or sub forms has errors (e.g. when rendering a long form a header message of "This form contains errors" or adding a class to a whole sub form to show an erroneous state) is currently very difficult/near impossible and may need the original form object being accessible in the view layer.

Whats a bit grey here is the best phrasing to use for this. Options I weighed up were is_valid (seemed a bit semantically incorrect in a template, since it would return true pre bind) and has_errors_deep (which i wasn't sure if it fitted naming conventions).

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

by travisbot at 2012-05-07T20:25:55Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1269345) (merged fe1f5aee into 919604ab).

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

by henrikbjorn at 2012-05-19T18:36:33Z

couldnt you just use `{% if errors %}` in your views?

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

by stof at 2012-05-19T19:17:20Z

@henrikbjorn ``errors`` contains only the errors attached to the form itself. It will not tell you when there is some errors in a child form.

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

by kevindew at 2012-05-22T10:43:45Z

Sure, done

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

by travisbot at 2012-05-22T10:45:12Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1399006) (merged 9f6658d4 into 517ae43f).

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

by kevindew at 2012-05-22T10:57:54Z

Shoot, sorry about that.

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

by travisbot at 2012-05-22T11:00:00Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1399096) (merged 88920591 into 517ae43f).

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

by bschussek at 2012-05-22T11:17:38Z

Can you squash the commits and prefix the message with "[Form]" please?

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

by travisbot at 2012-05-22T11:49:52Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1399390) (merged ca771822 into 517ae43f).

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

by kevindew at 2012-05-22T11:53:18Z

Sure, done (I've sorted the travis fail btw)

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

by travisbot at 2012-05-22T11:55:10Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1399404) (merged e92212ac into 517ae43f).

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

by bschussek at 2012-05-22T12:25:45Z

@fabpot :+1:
merged branch grEvenX/authorization_example_fix (PR #4370)

Commits
-------

0935964 Modified example for mod_rewrite to not add Authorization header if it is not set in the request

Discussion
----------

Correct example mod_rewrite to not add Authorization header that does not exists

The in-line PHP code comment suggest to do some changes in .htaccess with mod_rewrite to pass HTTP-Authorization header to PHP. This leads to the Authorization header being introduced even when it's not originally in the request (albit empty, the result of ParameterBag->has('Authorization') will return true when you expect it not to.
Some external libraries might check for this header and perform logic based on wether it was set or not (The php-oauth2 library in my case).

I suggest this fix which I think is a more proper way of handling the case anyway, since when the header is not set you don't expect it to exist in the ServerBag either.

(I tried to search the documentation for this but did not find it, but I guess this probably should go into the documentation somewhere?)

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

by travisbot at 2012-05-22T12:51:25Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1399753) (merged 0935964b into 517ae43f).