PUGX / PUGXAutoCompleterBundle

Add an autocomplete field to your Symfony forms
GNU Lesser General Public License v3.0
93 stars 38 forks source link

How to make the autocomplete field required ? #55

Closed vince83110 closed 4 years ago

vince83110 commented 5 years ago

I use the simple configuration :

->add('cli', AutocompleteType::class, [
          'label' => 'Le client*',
          'class' => TblClient::class,
         'required' => true
 ])

But the field is not required, I can let it empty and the user can submit the form. Is there something else to do ?

Thanks

garak commented 5 years ago

I'm afraid you need some client-side trick, e.g. something in javascript to add the required attribute to field, since the autocomplete field is not the same you're declaring in php/symfony

vince83110 commented 5 years ago

But Select2JS relies on the required attribute of the field it replaces. Why this plugin doesn't allow this easily ?

I tried this simple fiddle : http://jsfiddle.net/qsp3kgj8/

Only add required attribute to the input will work

garak commented 5 years ago

As mentioned in docs, this bundle does not support select2 version 4

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue is closed because was marked as stale and had no activity. Thank you for your contributions.