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

Translate filter on Select2 placeholder #388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Translate filter on Select2 placeholder #388

wants to merge 1 commit into from

Conversation

jcrombez
Copy link

Simple way to add a translate twig filter when using a placeholder on a select2.

Simple way to add a translate twig filter when using a placeholder on a select2.
@jcrombez
Copy link
Author

Any opinion from the maintainer(s) ?

@@ -656,6 +656,10 @@
<script type="text/javascript">
jQuery(document).ready(function($) {
$field = $('#{{ id }}');

{% if configs.placeholder is defined %}
{% set configs = {'placeholder': configs.placeholder|trans} + configs %}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{% set configs.placeholder = configs.placeholder|trans %}

would be better optmized.
Also a possibility to fetch the translation domain from the form config itself

Copy link

@benschumi benschumi Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neirda24, your code doesn't work.

Unexpected token "punctuation" of value "." ("end of statement block" expected) in GenemuFormBundle:Form:jquery_layout.html.twig at line 661.

The original method by jcrombez work well
{% set configs = {'placeholder': configs.placeholder|trans} + configs %}
but i prefer this
{% set configs = configs|merge({"placeholder": configs.placeholder|trans}) %}

@@ -656,6 +656,10 @@
<script type="text/javascript">
jQuery(document).ready(function($) {
$field = $('#{{ id }}');

{% if configs.placeholder is defined %}
{% set configs = {'placeholder': configs.placeholder|trans} + configs %}
Copy link

@benschumi benschumi Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neirda24, your code doesn't work.

Unexpected token "punctuation" of value "." ("end of statement block" expected) in GenemuFormBundle:Form:jquery_layout.html.twig at line 661.

The original method by jcrombez work well
{% set configs = {'placeholder': configs.placeholder|trans} + configs %}
but i prefer this
{% set configs = configs|merge({"placeholder": configs.placeholder|trans}) %}

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

Successfully merging this pull request may close these issues.

3 participants