Skip to content

Commit

Permalink
Remove read_only option definition from ModelAutocompleteType (sonata…
Browse files Browse the repository at this point in the history
…-project#3985)

This option is already provided by Symfony since v2.3.

Ref: http://symfony.com/doc/2.3/reference/forms/types/form.html#read-only

It's deprecated since v2.8 and removed since v3.0.

It has to be removed on next major.
  • Loading branch information
soullivaneuh authored and OskarStark committed Jul 5, 2016
1 parent f8b5421 commit f3ce22b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Form/Type/ModelAutocompleteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->setAttribute('minimum_input_length', $options['minimum_input_length']);
$builder->setAttribute('items_per_page', $options['items_per_page']);
$builder->setAttribute('req_param_name_page_number', $options['req_param_name_page_number']);
$builder->setAttribute('disabled', $options['disabled'] || $options['read_only']);
$builder->setAttribute(
'disabled',
$options['disabled']
// NEXT_MAJOR: Remove this when bumping Symfony constraint to 2.8+
|| (array_key_exists('read_only', $options) && $options['read_only'])
);
$builder->setAttribute('to_string_callback', $options['to_string_callback']);

if ($options['multiple']) {
Expand All @@ -65,7 +70,6 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['minimum_input_length'] = $options['minimum_input_length'];
$view->vars['items_per_page'] = $options['items_per_page'];
$view->vars['width'] = $options['width'];
$view->vars['read_only'] = $options['read_only'];

// ajax parameters
$view->vars['url'] = $options['url'];
Expand Down Expand Up @@ -119,7 +123,6 @@ public function configureOptions(OptionsResolver $resolver)
'multiple' => false,
'width' => '',
'context' => '',
'read_only' => false,

'placeholder' => '',
'minimum_input_length' => 3, //minimum 3 chars should be typed to load ajax data
Expand Down
1 change: 0 additions & 1 deletion Tests/Form/Type/ModelAutocompleteTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function testGetDefaultOptions()
$this->assertSame(false, $options['cache']);
$this->assertSame('', $options['width']);
$this->assertFalse($options['dropdown_auto_width']);
$this->assertFalse($options['read_only']);

$this->assertSame('', $options['url']);
$this->assertSame(array('name' => 'sonata_admin_retrieve_autocomplete_items', 'parameters' => array()), $options['route']);
Expand Down

0 comments on commit f3ce22b

Please sign in to comment.