GithubHelp home page GithubHelp logo

pugx / pugxautocompleterbundle Goto Github PK

View Code? Open in Web Editor NEW
93.0 7.0 39.0 152 KB

Add an autocomplete field to your Symfony forms

License: GNU Lesser General Public License v3.0

PHP 78.37% JavaScript 21.63%
php symfony bundle symfony-bundle hacktoberfest

pugxautocompleterbundle's Introduction

PUGXAutocompleterBundle

This bundle has a simple, specific purpose: adding an "autocomplete" (also known as "type-ahead") field. The typical use case is when you get a Many-to-One relation and you need to display a form with related entity. If related entity has many thousands of items, using the classic select is not suitable. Here comes this bundle.

Build Status

Documentation

Read the documentation

Installation

All the installation instructions are located in documentation.

License

This bundle is released under the LGPL license. See the complete license text.

About

PUGXAutocompleterBundle is a PUGX initiative.

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.

When reporting a bug, it may be a good idea to reproduce it in a basic project built using the Symfony Standard Edition with PUGXAutocompleterBundle installed, to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.

pugxautocompleterbundle's People

Contributors

andreybolonin avatar core23 avatar dependabot-preview[bot] avatar dependabot[bot] avatar dvapelnik avatar esteban-filardi avatar fiendo avatar garak avatar khasinski avatar lennix avatar leopro avatar marco-loche avatar micotodev avatar nicklog avatar restless-et avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pugxautocompleterbundle's Issues

Need help enabling the autocompleter in js file

Hi everyone,

I'm trying to install the PUGXAutoCompleterBundle on my website but i'm having troubles enabling it in the js file since i don't know what to reference in the urllist.

I've tried to do everything as close to the given example as possible so i wrote a getBookAction and a searchBookAction functions in my controller.
Trouble is i have no idea what to modify in this line :
$('#book').autocompleter({url_list: '/book_search', url_get: '/book_get/'});

PS : I don't know if it's linked but i couldn't find where to write the few twig lines before and i assumed so far that i could go without it. Maybe this is the source of my problem...

[{% for book in results -%}
{{ {id: book.id, label: book.name, value: book.name}|json_encode|raw }}
{%- if not loop.last %},{% endif -%}
{%- endfor %}]

Thanks in advance for any help you guys could give me.

Raug

Error with newAction

Hi, I have trouble with the current code. It's very easy to explain.

Here is my controller

public function new(Request $request, EntityManagerInterface $entityManager): Response
    {
        $announce = new Announce();
        $form = $this->createForm(AnnounceType::class, $announce, [
          'entity_manager' => $entityManager
        ]);
        $form->handleRequest($request);
...

Here is my form

...
    $form
    ->add('customer', AutocompleteType::class, [
              'label_format' => 'announce.customer',
              'class' => Customer::class,
              'attr' => [
                'class' => 'autocomplete_customer',
              ],
              'required' => false,
            ])
...

When I load the page, I have the error Return value of PUGX\AutocompleterBundle\Form\Transformer\ObjectToIdTransformer::transform() must be of the type string, null returned

To solve this problem, I only change the return definition into vendor from method PUGX\AutocompleterBundle\Form\Transformer\ObjectToIdTransformer::transform($object): string to to PUGX\AutocompleterBundle\Form\Transformer\ObjectToIdTransformer::transform($object): ?string

After that, not any trouble found.

Can you change it in source, or is it any reason to have transform strictly with string output ?

Avoid to load all the datas

I see that when I use AutocompleteType::Class for a field, doctrine load all the datas for the entity, could we avoid this?

thank you

Edit form shows entity id instead of name

After following documentation everything seems to work fine, I can type a "name" and autocomplete shows correct values, and when I choose an option, name is written on the field (see first image).

imagen

The problem is when I edit the entity, the autocomplete field shows the id instead of the name (see second image)

imagen

Am I missing some option?

These are my controller methods:

/**
 * Autocomplete query for clients, based on name
 *
 * @Route("/search/name/", name="client_search_name")
 * @Method("GET")
 */
public function searchClientLikeNameAction(Request $request)
{
    $q = $request->query->get('term'); // https://github.com/PUGX/PUGXAutoCompleterBundle/blob/master/Resources/doc/index.md
    $results = $this->getDoctrine()->getRepository('AppBundle:Client')->findLikeName($q);

    return $this->render('client/auto-complete.html.twig', ['results' => $results]);
}

/**
 * Autocomplete query for clients, based on name
 *
 * @Route("/get/", name="client_get")
 * @Method("GET")
 */
public function getClientAction($id = null)
{
    $client = $this->getDoctrine()->getRepository('AppBundle:Client')->find($id);

    return new Response($client->__toString());
}

A tree builder without a root node is deprecated

I'm seeing the following deprecation in symfony 4.2:

A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.

Are there plans to fix this?
Thanks for a very useful bundle!!

Not working with symfony's webpack 1.0 and stimulus 2.0

I have your bundle working with webpack 0.32 (using jquery-ui; had to add import 'jquery-ui/ui/widgets/autocomplete'; to app.js to get it going).

When I update to the recently released webpack 1.0, your bundle no longer works. I have no errors in my console. It looks like it does not start an async connection to fetch db results.

I'm uncertain what the problem is or how to help you debug.

Any thoughts?

cascade_validation

aggiungendo al setDefaultOptions in un formType la codizione cascade_validation a true il form cerca di salvare nuovamente l'entità gestita dall'autocomplete generando errori a catena

The CSRF token is invalid.

the autocomplete works fine, but I have a button off to the side where the user can submit the form, incase they didn't want to make one of the selections and just wanted to submit the query string (fake_#id).

When I try to submit the form I get CSRF token is invalid.

Symfony 5 compatibility

Problem 1
    - Installation request for pugx/autocompleter-bundle ^1.5 -> satisfiable by pugx/autocompleter-bundle[v1.5.0].
    - Conclusion: remove doctrine/common 3.0.2
    - Conclusion: don't install doctrine/common 3.0.2
    - pugx/autocompleter-bundle v1.5.0 requires doctrine/common ^2.8 -> satisfiable by doctrine/common[2.12.0, 2.13.0, 2.13.1, 2.13.2, 2.13.3, v2.10.0, v2.11.0, v2.8.0, v2.8.1, v2.9.0].
    - Can only install one of: doctrine/common[2.12.0, 3.0.2].
    - Can only install one of: doctrine/common[2.13.0, 3.0.2].
    - Can only install one of: doctrine/common[2.13.1, 3.0.2].
    - Can only install one of: doctrine/common[2.13.2, 3.0.2].
    - Can only install one of: doctrine/common[2.13.3, 3.0.2].
    - Can only install one of: doctrine/common[v2.11.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.10.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.8.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.8.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.9.0, 3.0.2].
    - Installation request for doctrine/common (locked at 3.0.2) -> satisfiable by doctrine/common[3.0.2].

url_get not mandatory

Hello, I can't figure what is the use of url_get.
Without this parameter everything works ok, but it return 2 errors (404)

I've a page with collection (an invoice with 'add a product'). The product name is an autocomplete.

If I complete the first row, and I click on 'add a product', it works but I see 2 404 error:
http://127.0.0.1:8000/invoices/1
http://127.0.0.1:8000/invoices/testprod

testprod is the name of the product, 1 is the ID of that product.
http://127.0.0.1:8000/invoices/purchase

If in url_get i write '/product/' the 404 error became:
http://127.0.0.1:8000/product/1
http://127.0.0.1:8000/product/testprod

So I think it's related to url_get parameter

Thank you

New tag?

Can you tag your recent changes to a new version (1.7.1 for example) so we can auto update projects? Thanks in advance!

Avoid dependencies on javascript libraries

As of 2020, this bundle offers 2 javascript libraries options:

  • Select2, but not the last version 4.
  • JQuery UI.

JqueryUI download page is now broken when using custom download. It has been like that for months (more than a year) and they state it will take some more months.

Using complete version of jqueryUI may confilct with some other plugins (that's my case) and using old version of Select2 also may lead to problems (I don't recall what exact problem I had but I couldn't use it either, maybe it forced to use an older version of some other library).

So, my question is: is there a built-in way to avoid using these libraries and implement my own? if not, do you plan to implement a built-in javascript list and avoid external dependencies? or at least... support last version of Select2?

Thank you.

New tag?

Can you tag your recent changes to a new version (1.8.1 for example) so we can auto update projects? Specifically looking for the new doctrine/persistence version from composer.json. Thanks in advance!

New release

Is there a status update, when we can expect a new release to support symfony 4?

Compatibility with Symfony 2.7

Hi,

I detected an issue on your bundle with Symfony 2.7 (I'm on v2.7.20 on a project).
I have this exception

Could not load type "Symfony\Component\Form\Extension\Core\Type\TextType"
in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php at line 83

After debug, I find issue on this file : PUGXAutoCompleterBundle/Form/Type/AutocompleteType.php method getParent()

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'Symfony\Component\Form\Extension\Core\Type\TextType';
    }

After several searches on Symfony documention I found this :

public function getParent()
    {
        return 'choice';
    }
public function getParent()
    {
        return ChoiceType::class;
    }

I don't test with SF 2.8 but your bundle version 1.2.6 was good for SF 2.7 : https://github.com/PUGX/PUGXAutoCompleterBundle/blob/v1.2.6/Form/Type/AutocompleteType.php#L67
And the code seems backwards compatible

 /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        // BC for Symfony < 3
        if (!method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) {
            return 'text';
        }
        return 'Symfony\Component\Form\Extension\Core\Type\TextType';
    }

Because getBlockPrefix method exist in symfony 2.8, 3.0 and 3.1 :

If you don't have any time I can made fix and pull request.

regards

Attempted to call an undefined method named

I am using SF3.2. and pugx/autocompleter-bundle 1.3 the same error is still persisting,

Attempted to call an undefined method named "getId" of class "Doctrine\Common\Collections\ArrayCollection".

This is my source codes

Controller actions

public function searchSocieteAction(Request $request){
        $q = $request->query->get('q');
        $results = $this->getDoctrine()->getRepository('BlogBundle:Societe')->FindLikeName($q);
        
        return $this->render('dossier/test.html.twig', ['results'=> $results]);
    }
    
    public function getSocieteAction($id = null){
        
        $societe = $this->getDoctrine()->getRepository('BlogBundle:Societe')->find($id);
        
        return $this->json($societe->getNom());
    }

My Routes

dossier_societe_list:
    path:     /liste/societe
    defaults: { _controller: "BlogBundle:Dossier:searchSociete" }
    methods:  [GET, POST]
    
    
dossier_societe_get:
    path:     /get/societe
    defaults: { _controller: "BlogBundle:Dossier:getSociete" }
    methods:  [GET, POST]

My template

{% extends 'base.html.twig' %}

{% block body %}
    <div class="container-fluid">
        <div class="row">
            <h2 class="text-center top50" style="padding: 7px;background-color: #e2e2e2;">test autocomplete </h2>

            [{% for societe in results -%}
            {{ {id: societe.id, label: societe.name, value: societe.name}|json_encode|raw }}
            {# use "value" instead of "id" key, if you use jquery-ui #}
            {%- if not loop.last %},{% endif -%}
                {%- endfor %}]

            </div>
        </div>

        <script type="text/javascript">
            var URL_listSocietes = Routing.generate('api_autocomplete_societes', {}, true),
                    URL_getSociete = Routing.generate('api_autocomplete_societe', {}, true);
            $('#dossier').autocompleter({
                dossier_societe_list: URL_listClients,
                dossier_societe_get: URL_getClient
            });
        </script> 

{% endblock %}

what did i missed? i coudn't rectify as i am new to this bundle.

Twitter bootstrap toogle issue

Hi,

This bundle works find, but I'm having a problem with my navbar since I've installed it.
Here is my javascript inclusion in my main layout (juste before ) :

{% javascripts 'bundles/myBundle/js/*' '@PUGXAutocompleterBundle/Resources/public/js/autocompleter-jqueryui.js' %}
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
    <script type="text/javascript" src="{{ asset_url }}"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  {% endjavascripts %}

and here is my toggle nav :

                  <ul class="nav navbar-nav pull-right">
                      <li class="dropdown pull-right">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                ME
                        <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                          <li><a href="#">link 1</a></li>
                          <li><a href="#">link 2</a></li>
                        </ul>
                      </li>
                  </ul>

I have no error in the console but the toggle doesn't work. And if I remove '@PUGXAutocompleterBundle/Resources/public/js/autocompleter-jqueryui.js' from the javascript block, the toggle works, but of course, not the autocomplete....

As I have no error in the console, I don't really understand what is the problem... any idea ?

Thank you

Error "Cannot read properties of undefined (reading 'toUpperCase')" when using select2 version 3.5.2-browserify

I've got this error only with select2. If I use jquery-ui it work but I want to implement select2.

My JS file :

import $ from 'jquery';
import 'select2/select2';
import '@pugx/autocompleter-bundle/js/autocompleter-select2';

$('#postal_code_search_zipcode').autocompleter({
    url_list: '/postalCode_search',
    url_get: '/postalCode_get/',
    // min_length: 3,
    otherOptions: {
        minimumInputLength: 3,
        formatNoMatches: 'Pas trouvé',
        formatSearching: 'Je cherche',
        formatInputTooShort: 'Insérer au minimum les 3 premiers chiffre'
    }
})

My Controller :

{
    #[Route('/postalCode_search', name: "postalCode_search", defaults:["_format" => "json"])]
    public function searchPostalCode(Request $request, CityRepository $cityRepository): Response
    {
        $query = $request->query->get('q');
        $results = $cityRepository->findLikePostalCode($query);

        return $this->render('json/postal_code.json.twig', ['postalCodes' => $results]);
    }

    #[Route('/postalCode_get', name: "postalCode_get")]
    public function getPostalCode(string $id, CityRepository $cityRepository): Response
    {
        $postalCode = $cityRepository->find($id);

        if (null !== $postalCode){
            $result = $postalCode->getZipcode().' '.$postalCode->getName();
        }else{
            $result = 'Aucun résultat';
        }

        return $this->json($result);
    }
}

My json twig :

[{% for postalCode in postalCodes -%}
    {{ {id: postalCode.id, label: postalCode.zipcode ~ ' ' ~ postalCode.name, value: postalCode.zipcode ~ ' ' ~ postalCode.name}|json_encode|raw }}
    {%- if not loop.last %},
    {% endif -%}
 {%- endfor %}
]

Any idea ?

assets bug

hello, in version 1.4.1 when i run bin/console assets:install, assets didn't install in to web/bundles
in 1.3.1 works fine.

thanks.

Impossible to set specific ajax option without erase all of default ajax options

Hi,

there is an issue in the autocompleter-select.js file which not allow to set specific ajax option.

at line 48

            if (settings.otherOptions) {
                $.extend(select2options, options.otherOptions);
            }

It will be more flexible to use the jQuery extend method in recursive mode like that

           if (settings.otherOptions) {
                $.extend(true, select2options, options.otherOptions);
            }

So on the initialisation of the autocompleter we can now set an ajax option like "quietMillis" or other options without erase all of the ajax options.

example

var options = {
        url_list: 'http://myurl.com/list',
        url_get: 'http://myurl.com/get',
        placeholder: 'Type text',
        otherOptions: {            
            minimumInputLength: 3,
            formatNoMatches: 'No entry match.',
            formatSearching: 'wait please...',
            formatInputTooShort: 'not enough letters',
            ajax: {
                  quietMillis: 1000 // <-- my new parameter !!!
            }
        }
    };

$('#my_input').autocompleter(options);

thank you very much.

Multiple

Hi, i wonder if this bundle support multiple selections.

[with jquery-ui] create a "response" callback function

Hello (again again),

There is a nice undocumented feature in your code (please document it!) allowing to add a javascript callback from the webpage's app.js code by setting parameter on_select_callback.

In my project I have had the need to add a function that is called when the "response" event is fired (this event is fired after the search request is complete, cf here ).

I added the following code to autocompleter-jqueryui.js to allow my code to hook a function to this event, by adding this:

// inside var settings = { ...
  on_response_callback: null // default setting, function does not do anything

// after the end of select: function (event, ui) {... },
response: function (event, ui) {
 if (settings.on_response_callback) {
  settings.on_response_callback($this, event, ui);
 }
}

It then becomes possible to add a response callback in app.js like this:

$('#mysearch').autocompleter({
 url_list: '/some-search',
 url_get: '/some-get/',
 min_length: 4,
 on_response_callback: function (autocompleteInstance, event, ui) { ... },
})

Many thanks in advance,

jQuery-UI scrip does not work because of wrong Ajax parameter names 'id' and 'text'

I was trying to use the bundle in my project, and couldn't get it working with jQuery-UI.
So I downloaded the demo project, changed the libraries and .js file to jQuery-UI, and got the same symptoms.

With jQuery-UI versions 1.12.1:
firefox_2016-12-22_18-07-41
1.11.4:
firefox_2016-12-22_18-09-40
1.10.4:
firefox_2017-01-03_09-54-28

It does not seem to be a CSS issue since all my stylesheets are loading fine.
The AJAX request also works and is not empty.
The HTML <li> elements are empty, though.

Symfony3

Is the package compatible with symfony 3? I can't install it with composer

Symfony3 - Could not load type "text"

Hi, I'm using your bundle with Symfony3.

This is my code:

public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder->add('book',AutocompleteType::class,array(
            'class'=>'AppBundle:Book'
        ));
}

When I want to use it, an error500 happens, saying Could not load type "text" (in vendor\symfony\symfony\src\Symfony\Component\Form\FormRegistry.php at line 87).
I guess, it has something to do with getParent() which returns 'text'. Is there a fix for that?

New release?

Any chance you could issue a new release incorporating latest changes (like fixed deprecations)? Thanks!

add minLength option to the js autocompleter

Hi Massi,
at the moment is not possible to pass the option minLength to the autocompleter-js, the option is usefull when you want to trigger the autocomplete only after typing n charaters.
This is a workaround:
https://gist.github.com/sound-code/33b971680f973784e304#file-autocompleter-jqueryui-js-L17

of course I think the best way would be to extend the jquery plugin so that all the option passed to the autocompleter goes to the jquery autocomplete.

thank you very much

Gianpiero

Small error in documentation

In the Controller "searchAuthorAction" the line
$q = $request->query->get('q');
should be
$q = $request->query->get('term');
Cause the request parameter is "term", not "q"

Thank you for this Bundle!

Can't make it working with Select2 4.0

Hi,
I can't make bundle working Select2 4.0 version (https://select2.github.io/), it now uses select instead of hidden text field. Im populating select2 field with ajax call and ajax is not working when I type something. I tried to modify AutocompleteType to set its parent type to choice, then ajax works but then nothing is passed to data transformer and it cant transform id to object and vice versa. When I dump request id is there but form->handleRequest won't accept value and nothing is passed to form or transformer (nothing in dump). Maybe choice type needs other data format but I cant make it work.

Small (I suppose) request

Hello Garak!
I'd really like to have some hook so that I can fire a function I'd pass to it if the user tries to submit a form without a valid entity in this field.
This could be useful in two cases:
1- if the default can be 'null' [I didn't try it in this way, though]
2- to give the user a chance to "create" the related entity with a popup form

TYVM

PS: Massimiliano, sono Piermaria della Gilda, ti ricordi di me vero?

Not working on ie

Hi @garak I found a little browser issue on Internet Explorer. I checked code and I watched the bundle use console.dir() command, and this stopped working on IE, so it work only with Console Inspection open.

I just hide with comment // console.dir() at 37 row of Resources/public/js/autocompleter-select2.js and everythings starts to work again in every browser.. ;)

PUGX/PUGXMultiUserBundle issue....

Sorry for posting this issue here but the GitHub issue tracker for the PUGXMultiUserBundle is throwing a 404 error.

I am having trouble making the profile Edit work.

Mainly one of two issues seems to occur:

  1. the profile edit of the FOS User bundle says: Method "user" for object "Symfony\Component\Form\FormView" does not exist in FOSUserBundle:Profile:edit.html.twig at line 14

That is what happens if try to access /profile/edit of the FOS User Bundle

  1. If I have my own Profile controller which I do and try to access my own profile edit method on disctinct controllers based on the discriminator class then the editAction comes up with a blank form.

Here is the code regarding that.... any help would be greatly appreciated.

container->get('pugx_user_discriminator'); $discriminator->setClass('MHO\VmpBundle\Entity\VmpPhysician',$persist = true); $form = $discriminator->getProfileForm(); $this->container->set('fos_user.profile.form', $form); ``` return $this->container->get('templating')->renderResponse('MHOVmpBundle:Profile:profile_vmp_physician.html.twig', array( 'form' => $form->createView(), )); } ``` } and here my form type class: add("username", "text", array( 'attr' => array( 'readonly' =>'readonly', 'class' => 'form-disabled' ))) ->add("email", "email", array( 'attr' => array( 'readonly' =>'readonly', 'class' => 'form-disabled' ))) ->add("firstname", "text", array( 'attr' => array( 'readonly' =>'readonly', 'class' => 'form-disabled' ))) ->add("lastname", "text", array( 'attr' => array( 'readonly' =>'readonly', 'class' => 'form-disabled' ))) ->add("middlename", "text", array( 'attr' => array('readonly' =>'readonly', 'class' => 'form-disabled' ))) ->add('suffix', "text", array( 'attr' => array( 'readonly' =>'readonly', 'class' => 'form-disabled' ))) ->add('homeAddress1', "text", array( 'label' => 'Address', )) ->add('homeAddress2', "text", array( 'label' => 'Address', 'required' => false, )) ->add('homeCity', "text", array( 'label' => 'City', )) ->add('homeState', "text", array( 'label' => 'State',)) ->add('homeZipCode', 'text', array('pattern'=>'[0-9]{5}', 'label' => 'Zipcode', 'attr'=>array( 'maxlength' => '5'))) ->add('officePhone', "text", array( 'label' => 'Office phone', )) ->add('fax') ->add('cellPhone', "text", array( 'label' => 'Mobile', )) ->add('npi', 'text', array('pattern'=>'[0-9]{10}', 'attr'=>array( 'maxlength' => '10'))) ; } public function getName() { return 'fos_user_profile_form'; } protected function buildUserForm(FormBuilderInterface $builder, array $options) { parent::buildUserForm($builder, $options); } ``` } Any ideas on what I could to get this to work?

Autocomplete doesn't respect executing environment

When running app in DEV environment (app_dev.php) the bundle calls search routes without app_dev.php prefix, this leads to some problems, one of them being necessary to delete cache for each modification, also can lead to session problems as (I think) sessions are independent in different environments.

Options "multiple" and "query_builder" don't exist

Hi.

I wanted to replace my "entity" type with PUGXAutocompleterType in a form, but OptionsResolver says that type doesn't support "multiple" (ManyToMany entity connection) or "query_builder" (standard for EntityType) options. Symfony 2.8, PUGXAutocompleter 1.2.
Any chances for support?

Regards.

Documentation overhaul

For example, the script does not work without a proper stylesheet, but this is eluded by a single "Don't forget to include your stylesheet files." and no link to the said files...

Also, switching between jquery and select2 is not clear, as many changes need to be done manually in the code. Maybe a global section about why choosing one or the other would be helpful.

Symfony 3

Hello, I'm using Symfony 3.
In FormType 'autocomplete' doesn't work

            ->add('book', 'autocomplete', array('class' => 'AppBundle:Book'))

I need to use

            ->add('product', 'PUGX\AutocompleterBundle\Form\Type\AutocompleteType', array(
                'class'=>'AppBundle\Entity\Product'
            ))

Also, Assetic is not available anymore, so

{% javascripts
    'js/jquery.js'
    'js/jquery-ui.js'
    '@PUGXAutocompleterBundle/Resources/public/js/autocompleter-jqueryui.js'
%}

doesn't work. Are known problems? Thank you

How to make the autocomplete field required ?

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

Can you publish your npm package on npm?

I'm working on upgrading this library to v1.7 and running into an issue generating assets. I've discovered in upgrading this package that it is adding a new line to my package.json:

"@pugx/autocompleter-bundle": "file:vendor/pugx/autocompleter-bundle/assets",

The problem I'm having here is that I generate my assets in a previous stage and container from where the PHP code runs so at the time npm install is run, not only does this bundle not exist, neither does composer for me to install this bundle. Here is an excerpt of what I mean:

FROM node:8.4.0-alpine as assets-builder
COPY /package.json /package-lock.json /application/
RUN npm install && npm run dump-assets

FROM php:7.4.16-fpm-alpine3.13 as prod
COPY composer.json composer.lock /application/
RUN composer install
COPY --from assets-builder /application/public /application/public
COPY . /application

I think this would all be resolved though if you could publish the npm package as npm could grab these assets through npm instead of the file system. Is that something that you're willing to do?

Error with Array Collection

Hello,

I'm encountering an error I am unable to understand. My form contains this line

->add('contacts', 'PUGX\AutocompleterBundle\Form\Type\AutocompleteType', array('class' => 'AppBundle:Client'))

And both controllers and routes are set as seen in documentation for search controllers (search and get).

I receive this error when calling the route :

Attempted to call an undefined method named "getId" of class "Doctrine\Common\Collections\ArrayCollection".

I don't really understand what's wrong.

Symfony version locked to 4.x or 5.x; need 6.x

While attempting to update my application to symfony 6.0, composer would not install because this package requires symfony 4.x or 5.x. Please consider allowing 6.x in your composer.json file.

Thanks!

jquery-ui and related json template

Hello,
I'm using autocomplete-bundle with symfony 5 in a form. I'm using the bundle with jqueryui because select2 has accessibility issues for screenreaders.
All works fine, but I don'to know how can I solve a problem:
In documentation you say that I have to replace id with value using jqueryui. It works but when I'm writing in the field text it shows ids instead labels. When I confirm the choice it shows, correctly, the label.
I tried also to put another value with label but it overwrite the first value and I do not have ids anymore.
Do you Know how can I solve this problem?
Thank you in advance

Documentation : searchCityAction

For beginners, I think the following lines are insufficient :

public function searchCityAction(Request $request)
    {
        $q = $request->get('term');
        $em = $this->getDoctrine()->getManager();
        $results = $em->getRepository('AppBundle:GeoCity')->findLikeName($q);

        return array('results' => $results);
    }

Why not add the following annotation :
* @template(":folder:city.html.twig")
or rendering a template like they said in best practices ? :)

setting options when using jquery-ui

Hi (again)!

The section "3.1 Select2 options" says how to add options to the autocompleter widget.

Some options also work using jquery-ui, the syntax is a little different however:

var options = {
url_list: $('#url-list').attr('href'),
url_get: $('#url-get').attr('href'),

// for select2
// otherOptions: { 
//    minimumInputLength: 3,
// }

// for jquery-ui
min_length: 3

};
$('#book_author').autocompleter(options);

Is it possible to either normalize the code so that setting options becomes independent from the library used, or document the way to set options for both libraries?

Many thanks in advance,

Confusion with LexikFormFilterBundle usage

Hello,

A bit of a noob question (but since I'm quite new to Symfony, forgive me). I`m trying to create an auto-complete select box for a project where users can search addresses.

I have followed the documentation up until here, however I`m a bit confused of the usage.

My understanding was and is that if I use LexikFormFilterBundle with your library it would search from the entity/database without the need to have a separate controller. However, I can see that the library still tries to perform GET requests to a controller.

Is this the desired result and I am missing something? Please advise.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.