10000 [Form] deprecate read_only option by Tobion · Pull Request #14403 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] deprecate read_only option #14403

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
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Form] deprecate read_only option
  • Loading branch information
Tobion committed Apr 18, 2015
commit 72846802ddc25a680b91300eedbeffcd422bf00a
14 changes: 13 additions & 1 deletion src/Symfony/Component/Form/Extension/Core/Type/FormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,22 @@ public function configureOptions(OptionsResolver $resolver)
return $attributes;
};

$readOnlyNormalizer = function (Options $options, $readOnly) {
if (null !== $readOnly) {
trigger_error('The form option "read_only" is deprecated since version 2.7 and will be removed in 3.0. Use "attr[\'readonly\']" instead.', E_USER_DEPRECATED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be 2.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch


return $readOnly;
}

return false;
};

$resolver->setDefaults(array(
'data_class' => $dataClass,
'empty_data' => $emptyData,
'trim' => true,
'required' => true,
'read_only' => false,
'read_only' => null,
'max_length' => null,
'pattern' => null,
'property_path' => null,
Expand All @@ -209,6 +219,8 @@ public function configureOptions(OptionsResolver $resolver)
'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
));

$resolver->setNormalizer('read_only', $readOnlyNormalizer);

$resolver->setAllowedTypes('label_attr', 'array');
}

Expand Down
0