Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
How can I use Yii 1.1 translation inside a CJavaScriptExpression?

I have the following code:

<?php 
    $this->widget('zii.widgets.jui.CJuiButton',array(
    'name'=>'save',
    'caption'=>Yii::t('app', 'Save'),
    'htmlOptions'=>array(
        'style'=>'
                 background: #EA7500;
                 color: white;',
    ),
    'onclick'=>new CJavaScriptExpression(
        'function(){
            swal("Saved", 
                "Successfully saved", 
                "success");
            saveInputFunction();
            return false;
        }'
    ),
)); ?>

I want to translate "Saved" and "Successfully saved" using Yii::t("app", "Saved"), however I'm not finding the correct syntax.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I called a js function in 'onclick' parameter and sent the translated message via ajax using an action that I wrote in the controller.

<?php
    $this->widget('zii.widgets.jui.CJuiButton',array(
        'name'=>'save',
        'caption'=>Yii::t('app', 'Save'),
        'htmlOptions'=>array(
            'style'=>'
                 background: #EA7500;
                 color: white;',
        ),
        'onclick'=>'js:function(){
                        updateInput();
                        return false;
                    }',
    )); 
?>


<script>
    function updateInput(){
        //code
    }
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda