Different caption on radio buttons

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
peteraj
Posts: 27
Joined: 2016-02-05 12:25

Different caption on radio buttons

Post by peteraj » 2016-04-13 07:13

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 7924 times

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Different caption on radio buttons

Post by AhmedBR » 2016-04-13 15:11

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
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Different caption on radio buttons

Post by AhmedBR » 2016-04-13 16:03

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
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

peteraj
Posts: 27
Joined: 2016-02-05 12:25

Re: Different caption on radio buttons

Post by peteraj » 2016-04-13 17:27

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

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Different caption on radio buttons

Post by AhmedBR » 2016-04-13 17:42

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.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

peteraj
Posts: 27
Joined: 2016-02-05 12:25

Re: Different caption on radio buttons

Post by peteraj » 2016-04-13 18:31

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...

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Different caption on radio buttons

Post by AhmedBR » 2016-04-13 21:56

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.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

peteraj
Posts: 27
Joined: 2016-02-05 12:25

Re: Different caption on radio buttons

Post by peteraj » 2016-04-15 15:12

How about in the detail view / input form? Special characters there also?

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Different caption on radio buttons

Post by AhmedBR » 2016-04-15 15:46

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.)
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

Post Reply