Skip to content

Commit cc244d4

Browse files
author
Sergio gallego
committed
prepare formtype for auto remote_route
1 parent da87e1a commit cc244d4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Form/Type/Select2EntityType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public function finishView(FormView $view, FormInterface $form, array $options)
119119
if ($options['multiple']) {
120120
$view->vars['full_name'] .= '[]';
121121
}
122+
123+
$view->vars['class_type'] = $options['class_type'];
122124
}
123125

124126
/**
@@ -169,6 +171,7 @@ public function configureOptions(OptionsResolver $resolver)
169171
'req_params' => array(),
170172
'property' => null,
171173
'callback' => null,
174+
'class_type' => null,
172175
)
173176
);
174177
}

Resources/public/js/select2entity.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
data: function (params) {
6464
var ret = {
6565
'q': params.term,
66-
'field_name': $s2.data('name')
66+
'field_name': $s2.data('name'),
67+
'class_type': $s2.data('classtype')
6768
};
6869

6970
var reqParams = $s2.data('req_params');

Resources/views/Form/fields.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
{% set attr = attr|merge({'data-width': width}) %}
3737
{% endif %}
3838

39+
{% if class_type %}
40+
{% set attr = attr|merge({'data-classtype': class_type}) %}
41+
{% endif %}
42+
3943

4044
{% spaceless %}
4145
<select {{ block('widget_attributes') }}>

0 commit comments

Comments
 (0)