symfony2admingenerator / AvocodeFormExtensionsBundle

(old-legacy) Symfony2 form extensions for Admingenerator project (also working standalone!)
Other
48 stars 31 forks source link

select2_entity is not initialized in view #92

Closed soeren-helbig closed 10 years ago

soeren-helbig commented 10 years ago

hey there, i used select2_entity before prefix-refactoring. now i updated my vendors, and the afe_select2_entity type stopped working. after a little try, i discovered the additional js-initialization is not done. please, tell me if i am wrong, shouldn`t this be done by the following twig-function:

afe_form_javascript(form)

my javascript block:

{% block javascripts %}
    {{ parent() }}

    {% include 'AvocodeFormExtensionsBundle::javascripts.html.twig' %}
    {% if form is defined %}
        {{ afe_form_javascript(form) }}
    {% endif %}
{% endblock %}
sescandell commented 10 years ago

Hi @soeren-helbig ,

Yes you're right, you should now use {{ afe_form_javascript(form) }}

i discovered the additional js-initialization is not done

Could you please precise "js-initialization is not done". What did you expect? What do you have?

Thank you for your contribution,

soeren-helbig commented 10 years ago

Hey @sescandell ,

sry, of course this information is important ;) i expected the following script-tag to be rendered

<script>
$(FORM_TYPE).select2()
</script>

but in my case this does not happen. instead the twig extension {{ afe_form_javascript(form) }} returns a empty value.

sescandell commented 10 years ago

Ok,

I'll check prototype integration this afternoon.

Keep in touch...

soeren-helbig commented 10 years ago

nice, thx!

Restless-ET commented 10 years ago

I think that for some reason the block _afe_select2_afejavascript contained on file form_javascripts.html.twig (starts at line 319) is not being rendered. Unfortunately I was not able to find the what's causing it for this specific block. :( I believe this was working fine before the "afe_" prefix renaming..

Changing the block name as follows solves the issue although I'm not sure if that's the best solution to apply here...

{% block afe_select2_entity_afe_javascript %}
{% spaceless %}
{% autoescape false %}
<script type="text/javascript">
    jQuery(document).ready(function($) {
        $field = $('#{{ id }}');

    {% block afe_select2_afe_javascript_prototype %}
        $field.select2({{ configs|e4js }});
    {% endblock afe_select2_afe_javascript_prototype %}
    });
</script>
{% endautoescape %}
{% endspaceless %}
{% endblock afe_select2_entity_afe_javascript %}

Would replicating this block for each select2_* (much like it's done for double_list related blocks on this same file) be an acceptable solution?

Restless-ET commented 10 years ago

Meanwhile I think I've found what's really causing the problem... I'll submit a PR.

sescandell commented 10 years ago

Closed thanks to #96