Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable / disable form in configuration #24269

Closed
steevanb opened this issue Sep 20, 2017 · 7 comments
Closed

Enable / disable form in configuration #24269

steevanb opened this issue Sep 20, 2017 · 7 comments

Comments

@steevanb
Copy link

steevanb commented Sep 20, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.3.*

Hi !

In app/config/config.yml, this 2 configurations should have same behavior :

framework:
    form: ~
framework:
    # no form key

But first one enable form, and second one, disable it (framework.form.enabled default value is false : https://symfony.com/doc/current/reference/configuration/framework.html#reference-form-enabled)

Or maybe ~ is not exactly same as "default values" ?
In this case, how can we know differences between ~ and default values ?

@chalasr
Copy link
Member

chalasr commented Sep 20, 2017

This is a documentation issue, as of 3.3 the framework.form.enabled config option is default true if you are requiring symfony/symfony.

@chalasr
Copy link
Member

chalasr commented Sep 20, 2017

See symfony/symfony-docs#8412

@chalasr chalasr closed this as completed Sep 20, 2017
@steevanb
Copy link
Author

So, i don't understand why form: ~ and no form key does not have same behavior ?

@chalasr
Copy link
Member

chalasr commented Sep 20, 2017

Just tried out, not adding the form key at all gives enabled: false at end. ping @ogizanagi

@chalasr chalasr reopened this Sep 20, 2017
@steevanb
Copy link
Author

When i dump Configuration object, i have 2 properties : $defaultValue = false, and $default = true.

I'm not sure about it, but maybe when you define form key, default value is readed in $default, not $defaultValue ?

@ogizanagi
Copy link
Member

ogizanagi commented Sep 20, 2017

If you're using the fullstack (symfony/symfony), the framework.form node is built using canBeEnabled (for BC reasons, as the original way before the framework Configuration object was tweaked in #21196 was to have everything disabled by default).

So

framework:
    form: ~

is not the same as

framework:
    # no form key

because canBeEnabled treats null as ['enabled' => true]. The ~ char in yaml does not mean "take default values". It's just null. What is really configured behind depends on the way the node was built.

#21196 changed the framework Configuration object for Flex projects in order to cleverly auto-enable available features according to the components you've installed. So given you're using flex in your project instead of the fullstack and have the symfony/form component installed, canBeDisabled is used, which means no framework.form key is even required, as it defaults to ['enabled' => true] when not set.

So in conclusion, I see no issue here, unless I missed something.

Thanks for opening this though. We should probably upgrade the documentation to explain how defaults behaves with Flex. symfony/symfony-docs#8412 will be a good start.

@steevanb
Copy link
Author

Ok, to me, that's a bug.

But if you don't think so ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants