textFiled htmlOption and Locale

Hi all,

as wrote on topic title I have a big problem with textField htmlOption string and Locale.

This will be the result:




<?php echo $form->textField($Profile, 'name', array('class'=>'noteInput', 'placeholder'=>'What is your first name?')); ?>



To implement multi language I modified in this way:




<?php echo $form->textField($Profile, 'name', array('class'=>'noteInput', 'placeholder'=>Locale::Translate("NAME_PLACEHOLDER"))); ?>



Locale::Translate read string from a ini file and stamp the translation with ‘echo’. Locale::Translate return this string: ‘What is your name?’.

The result is that the string ‘What is your name?’ is printed before the input element and not as placeholder.

Input Html code producted is:




<input class="noteInput" name="Profiles[name]" id="Profiles_name" type="text" maxlength="50">



How I can resolve this problem?

Tkx to all!

Are you saying that the call to Locale::Translate($str) echoes the translation rather than returning it?

If so, either:

Alter the method to return the translation rather than echoing it. Update your existing code base to use the updated method correctly.

Or, if you have lots of code already using your translation method:

Create a new method in Locale called something like Locale::getTranslation($str) which returns the translation instead of echoing it.

tkx a lot…

now work!