Checkbox selected from readdata

mobusag 17 Jan, 2025

Hello everyone, I have the following problem. I have a table that I output in CF8, and based on the FAQ, I’ve set up an edit page and mapped the fields in it. So far, so good. However, I have a checkbox group that is not being pre-selected correctly. What do I need to enter into the SelectedValue to correctly assign the data read from the database?

An example:read_data7 returns the following:

Array (

[option] => com_chronoforms8 [action] => view [chronoform] => fahrer [chronopage] => bearbeiten [id] => 54 [name] => Tester [vorname] => Test [kat] => ["B","C"] )

The kat field is the selection, and I would like it to be pre-selected in the edit section so that I can also modify it.

Thanks for a quick response.

Best regards,bambid

Max_admin 17 Jan, 2025
Answer

Hi bambid

you should enter in the Selected Values:

{var:read_data7.kat}

But I think this is the same issue reported in the topic below, it has been fixed but the fix requires the new update:

https://www.chronoengine.com/forums/topics/view/111535/can-not-set-multi-selected-value-for-multi-selection-dropdown

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 20 Jan, 2025

Hello Max,

Thanks for your reply. I have the latest version 8.0.37, but

{var:read_data7.kat}

is not working.

Do you have any further suggestions?

bambid

kittisak 24 Jan, 2025
1 Likes

Hi mobusag,  You should to wait for next version (8.0.38)

Max_admin 25 Jan, 2025

the new update is out, please try the fix now and let me know!

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 19 Feb, 2025

Hello Max,I have now installed version 39, but there is no change. If I select only one option, it works. However, if I select multiple options, none are selected.

Here is my PHP code that generates the output:

$katJson = $this->data['kat'] ?? '';

// JSON-String sicher in ein PHP-Array konvertieren
$katArray = json_decode($katJson, true);

// Prüfen, ob die Umwandlung erfolgreich war
if (is_array($katArray)) {
    return implode(" ", $katArray);
}

The result is as follows:

B C

Even with:

$katJson = $this->data['kat'] ?? '';

// JSON-String sicher in ein PHP-Array konvertieren
$katArray = json_decode($katJson, true);

// Prüfen, ob die Umwandlung erfolgreich war
if (is_array($katArray)) {
    return implode(",", $katArray);
}

The result is as follows:

B,C

 it doesn't work.

My Array looks like:

Array
(
    [option] => com_chronoforms8
    [action] => view
    [chronoform] => fahrer
    [chronopage] => bearbeiten
    [id] => 67
    [order_by] => name:asc
    [name] => Muster
    [vorname] => Paul
    [kat] => ["B","C"]
)

Can you tell me if I am doing anything else wrong?

Kind regards bambid

Max_admin 19 Feb, 2025

You do not need to decode, you can add your column to the JSON fields list in the Read Data

This setup works for me:

Checkbox selected from readdata image 1

This is the result:

Checkbox selected from readdata image 2

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 19 Feb, 2025
1 Likes

Hello MaxThx. With the following Code it works:

$katJson = $this->data['kat'] ?? '';

// JSON-String sicher in ein PHP-Array konvertieren
$katArray = json_decode($katJson, true);

// Prüfen, ob die Umwandlung erfolgreich war
if (is_array($katArray)) {
    return $katArray; // Direkt das Array zurückgeben
}

Kind regards

Max_admin 19 Feb, 2025

Thanks for sharing the solution.

I'm not sure how do you get data["kat"] but if its from the db table then you can use the json fields directly

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 19 Feb, 2025

Hello Max,

Thank you! But the direct way via {var:read_data7.kat} doesn’t work for me, even though both outputs are the same when I display them in a text field.

kind regards

Max_admin 19 Feb, 2025

did you add kat to the JSON Fields in your Read Data ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 19 Feb, 2025

Hello Max

Yes, 

{var:read_data7.kat}

but it won't work

Kind regards

Max_admin 19 Feb, 2025

it will show in the debug under read_data7 as 

["B","C"]

if you had it setup correctly

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 19 Feb, 2025

Hello Max, here is a picture.

The upper part is generated via PHP, and the lower part is created using readdata. The output in the text field is what I have also stored in the selected option, but it doesn't seem to work.

Could it be due to the characters? I can't imagine that, but anything is possible. ;-)

Best regards,Bambid

You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger