Page 1 of 1

Different caption on radio buttons

Posted: 2016-04-13 07:13
by peteraj
Hi all,

I have a set of radio buttons, which I would like to present with a different label than the option that gets stored in the db! The reason is that I want to translate the options into danish, but these words contain special characters like æ, ø, å, which doesn't work very well with our server!

Any suggestions?

Best Regards
Peter
RadioButtons.png
RadioButtons.png (3.69 KiB) Viewed 7929 times

Re: Different caption on radio buttons

Posted: 2016-04-13 15:11
by AhmedBR
Peteraj,

I have similar (exact) problem with Portuguese, all you have to do is use the equivalent from this table:
https://www.ime.usp.br/~glauber/html/acentos.htm

In your case you would use

Code: Select all

Grøn
this will show correctly on your webpage ;)

Hope this helps.

Have a nice day.
Ahmed

Re: Different caption on radio buttons

Posted: 2016-04-13 16:03
by AhmedBR
In some cases you might need to use the second table in the same link, and you would use this instead:

Code: Select all

Grøn

Re: Different caption on radio buttons

Posted: 2016-04-13 17:27
by peteraj
Thank you very much Ahmed! :-)

But if I change it, either in Appgini, or directly in the xxx_dml.php file, it will also store that value in the database! From that value, I construct a filename of an icon corresponding to the color (see http://bigprof.com/appgini/tips-and-tut ... eview-data), and that when it goes wrong! The database can handle the special characters, but PHP and Linux can't.... That's why I want to show the option "Grøn" to the user, but store "Green" (or a number) in the database.

I hope I have made myself clear? :-)

Have a nice evening
/Peter

Re: Different caption on radio buttons

Posted: 2016-04-13 17:42
by AhmedBR
I know what you mean, this is how I handle it (works very well, and have not found anything better yet):

In database I would use letters without any special marks (take a look at third letter it is special character):
Saida in database I would use Saida and in HOOK file INIT I would read the the database and change the value before showing it:

See reading Saida and Showing Saída using this Saída, and another one Preco and show Preço:

Code: Select all

        // modify the status field of the table view query to display 'Due' invoices in bold red
		$oldArray=$options->QueryFieldsTV;
		$options->QueryFieldsTV='';
		foreach($oldArray as $field => $caption){
			if($field=='`StockTransactions`.`Operation`'){
				$options->QueryFieldsTV['IF(`StockTransactions`.`Operation`=\'Saida\',
                 \'<b style="color: red;">Sa&iacute;da</b>\',
    .........................
    

Code: Select all

        // modify the status field of the table view query to display 'Due' invoices in bold red
		$oldArray=$options->QueryFieldsTV;
		$options->QueryFieldsTV='';
		foreach($oldArray as $field => $caption){
			if($field=='`StockTransactions`.`Operation`'){
				$options->QueryFieldsTV['IF(`StockTransactions`.`Operation`=\'Preco\',
                 \'<b style="color: red;">Pre&ccedil;o</b>\',
    .........................
    

This way your link etc will use GRON.
Special characters are always a problem for us :lol: :lol:

You will need to work on something like this.

Re: Different caption on radio buttons

Posted: 2016-04-13 18:31
by peteraj
Yes Ahmed, special characters will always be a huge problem! ;-)

In your example, do you show Saída and Preço as options, for the users to select, or Saida and Preco? my problem is that I wan't to show the special characters in the form, but store them as "nomal" characters in the database...

Re: Different caption on radio buttons

Posted: 2016-04-13 21:56
by AhmedBR
Yes, this is exactly what happens.

Saída and Preço (with special characters) only show on website (app) for the user.

in database no special character just Saida and Preco without any special characters.

Re: Different caption on radio buttons

Posted: 2016-04-15 15:12
by peteraj
How about in the detail view / input form? Special characters there also?

Re: Different caption on radio buttons

Posted: 2016-04-15 15:46
by AhmedBR
In detail view / input form usually there is no need to do anything special or even use this table.
The ONLY thing you need to do is use character encoding: Unicode UTF-8
Works very well with special characters in Portuguese (your characters should not be that different, since we have things like: ç ò ó â ã etc.)