window.select2Country = function () {
const $select2 = $('.select2SearchCountry');
const autocompleteUrl = $select2.data('autocomplete-url');
$select2.select2({
ajax: {
url : autocompleteUrl,
data : function data (params) {
return {s: params.term};
},
dataType : 'json',
processResults: function processResults (data) {
return {results: data};
}
}
});
};
public function getParent() {
return HiddenType::class;
}
илиextends HiddenType
->add('stars', ChoiceType::class, [
'attr' => ['class' => 'form-control select2'],
'label' => 'hotel.field.stars',
'translation_domain' => 'hotel',
'choices' => HotelStars::getChoiceArray(),
'multiple' => false,
])
$form = $this->getDTOForm($dto);
$form->add('save', SubmitType::class, [
'label' => 'app.crud.create',
'attr' => [
'class' => 'btn btn-success mt-3',
],
]);
$form->handleRequest($request);
//dump($request->get('hotel_form_builder'));
// dump($request);
//dump($form->getName());
//die;
if ($form->isSubmitted() && $form->isValid()) {...}
Приходяд значения, которых нет в choices родительского типа формы
hotel_form_builder