Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

genemu autocompleter (entity) + type: annotation #395

Open
Raug opened this issue May 21, 2015 · 0 comments
Open

genemu autocompleter (entity) + type: annotation #395

Raug opened this issue May 21, 2015 · 0 comments

Comments

@Raug
Copy link

Raug commented May 21, 2015

Hello everyone,

i'm trying to implement an autocompleting field in a symfony form 2 using the genemu bundle.

i'm trying to follow the instructions given in the documentation and on this issue :
http://stackoverflow.com/questions/26518405/symfony2-autocomplete-form-bundle

But as soon as i try to add the type : annotation line, i get a 500 error and i can't figure out why.

here's routing.yml


etat_stock_ajaxcommande:
    defaults: { _controller: EtatStockBundle:Export:ajaxcommande }
    pattern: /ajaxcommande/
    type:     annotation

the controller :


use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

...->add('member', 'genemu_jqueryautocompleter_entity', array(              
                                'class' => 'EtatStockBundle:Flux',
                                'route_name' => 'etat_stock_ajaxcommande',
                                'property' => 'codeArticle',
                                // 'multiple' => true
                            ))

/**
     * @Route("/ajaxcommande/", name="etat_stock_ajaxcommande")
     */
    public function ajaxcommandeAction(Request $request) {

        $value = $request->get('id');
        
        $commande = $this->getDoctrine()
                        ->getManager()
                        ->getRepository('EtatStockBundle:Flux')
                        // ->findAjaxValue($value);
                        ->findAll();
        
        $json = array();
        foreach ($commande as $commande) {
            $json[] = array(
                'label' => $commande->getCodeArticle(),
                'value' => $commande->getCodeArticle()
            );
        }

        $response = new Response(json_encode($json));
        $response->headers->set('Content-Type', 'application/json');
        return $response;
    }

and layout.html.twig


{% block stylesheet %}
    ....
    {% if form is defined %}
      
      {{ form_stylesheet(form) }}
    {% endif %}
  {% endblock %}
  ...
  {% block scripts %}
    ...
    {% if form is defined %}
      <script src="{{ asset('js/tinymce/js/tinymce/tinymce.min.js') }}"></script>
  <script src="{{ asset('js/select2-4.0.0/dist/js/select2.min.js') }}"></script>
  {{ form_javascript(form) }}
{% endif %}

{% endblock %}

if i go directly to the ajaxcommande route in my browser, i can see very entry listed correctly until i use the anootation type.

if i comment the type:annotation the site loads although the autocompleter doesn't work.

Any idea what could be the problem ?
If the autocompleter needs the type : annotation then the error comes from the fact that i can't use them for now.
If not then it doesn't work as is and i don't know why...

Thanks in advance,

Raug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant