-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Changes from 1 commit
7284680
052168f
83db940
40f4440
f0dfd2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1512,7 +1512,10 @@ public function testHidden() | |
); | ||
} | ||
|
||
public function testReadOnly() | ||
/** | ||
* @group legacy | ||
*/ | ||
public function testLegacyReadOnly() | ||
{ | ||
$form = $this->factory->createNamed('name', 'text', null, array( | ||
'read_only' => true, | ||
|
@@ -2119,14 +2122,13 @@ public function testWidgetAttributes() | |
$form = $this->factory->createNamed('text', 'text', 'value', array( | ||
'required' => true, | ||
'disabled' => true, | ||
'read_only' => true, | ||
'attr' => array('maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), | ||
'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), | ||
)); | ||
|
||
$html = $this->renderWidget($form->createView()); | ||
|
||
// compare plain HTML to check the whitespace | ||
$this->assertSame('<input type="text" id="text" name="text" readonly="readonly" disabled="disabled" required="required" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value" />', $html); | ||
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value" />', $html); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand, this doesn't preserve BC here? The test was changed to support the new way (through attributes), but the old way is not tested anymore. This created a BC break for us when migrating from 2.7 to 2.8. We have to switch from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mnapoli what exactly is breaking except the position in the string ? One would just expect to get the attribute here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before (2.7) passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the change we had to do: {% block _form_category_name_widget %}
- {% set read_only = true %}
{% set attr = {
'data-target-show': '.choose-categories',
+ 'readonly': true,
} %}
{{ block('form_widget_simple') }}
{% endblock %} |
||
} | ||
|
||
public function testWidgetAttributeNameRepeatedIfTrue() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnapoli Ok
so to avoid the BC break, we just need to add a line here with:Wrong this has to be done in the form theme.