-
Notifications
You must be signed in to change notification settings - Fork 263
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
base: master
Are you sure you want to change the base?
Conversation
Simple way to add a translate twig filter when using a placeholder on a select2.
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 %} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 %} |
There was a problem hiding this comment.
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}) %}
Simple way to add a translate twig filter when using a placeholder on a select2.