Skip to content

[Form] Deprecate "read_only" option #10658

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

Closed
webmozart opened this issue Apr 9, 2014 · 5 comments
Closed

[Form] Deprecate "read_only" option #10658

webmozart opened this issue Apr 9, 2014 · 5 comments
Labels
Enhancement Form Good first issue Ideal for your first contribution! (some Symfony experience may be required)

Comments

@webmozart
Copy link
Contributor

The option "read_only" has no real functionality anymore and should be deprecated. The attribute can be set via the "attr" option instead.

See #10533 for details.

@sdecandelario
Copy link

Hello @webmozart I want to start contribuiting in symfony, and i want to get some easy pick. I read the option read_only must be deprectated, but i don't know how to start in this issue. Can you give me some help or some ideas. Thanks for all.

@wouterj
Copy link
Member

wouterj commented Jul 28, 2014

@Hades87 as you can see in the references above your comment, someone already opened a PR about this: #10676

So well, let's find a simple starter issue you can work on.......
I must admit, it was quick a long search to find a simple issue to work on, but I think I've found one for you: #7832 It's about renaming options. This basically means doing 2 things:

  • Find all usages of the options you have to rename and replace them with a new name
  • Readd this line: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/Type/FormType.php#L197 (so you end up with both the new and the old option name) and create make the default value of the new option be based on the value of the old option (read about it in the docs). That way, peopling using that application don't have to revisit their code to update the name. That's what we call Backwards Compatibility. It would be nice if you add a comment to this option that it is deprecated and that they need to use the new name.
  • Also make sure you add the changes (about deprecating option X in favor of option Y) in the CHANGELOG file, located in the Form component root.

If you have any questions, feel free to ask them in that particular issue, on IRC (#symfony), etc.

Good luck coding!

@sdecandelario
Copy link

Thanks for your help @wouterj i take the issue and ask something in the correspondent thread.

@marfillaster
Copy link
Contributor

-read only still serves its purpose when disabled option is not applicable.

I had this problem when a disabled field failed validation but still passes the containing form as valid. This was not the behavior in pre 2.5 api where even disabled field invalidates the form. Although I find this new behavior the expected one.

but i agree that it should be an attr instead

@peterrehm
Copy link
Contributor

@webmozart Is there the posibility to have a field readonly / disabled with validation on the field but not altering the model data?

A use case can be that only some have the permission to modify a field which is necessary to process but someone else is then processing the next step after this required field has been submitted.

fabpot added a commit that referenced this issue May 20, 2015
This PR was squashed before being merged into the 2.8 branch (closes #14403).

Discussion
----------

[Form] deprecate read_only option

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #10658
| License       | MIT
| Doc PR        | symfony/symfony-docs#3782

Replaces #10676 with a slightly different implementation.
- fixes BC break when 'read_only' => true option and at the same time custom attributes are used by using a normalizer
- adds deprecation notice
- keeps legacy tests

Commits
-------

53330e1 [Form] deprecate read_only option
@fabpot fabpot closed this as completed May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Form Good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

7 participants