Checkbox not showing as checked

Display a checkbox as checked based on database values in ChronoForms.

Overview

The issue occurs because the checkbox field does not automatically show as checked when its value is set to "1" from the database.
Apply a patch to fix the output of the extra attribute function, which ensures the checkbox is properly marked as checked when the corresponding database value is "1".

Answered
Connectivity v6
ct ctrlmedia 20 Apr, 2017
Hi,
I have a table which lists records. I have a column called notes where I was able to replace the value with a textarea field with the value within it - this works fine. (eventually I want to make the data updatable)

I have done the same with a checkbox. I have a column of checkboxes (check to mark as completed) in the DB the column is filled with 0's and 1's. 1 equals completed.

The values seem to be being brought in to the checkboxes OK but they are not displaying as checked.

In the checkbox I have
Name = completed[{var:ListIssues.row.Issues.cckey}]
Value = {var:ListIssues.row.Issues.completed}

Do I need to write some jquery that says if value is 1 checkbox = checked, or should it be checked by default?

Oh, I also don't understand what the Enable Ghost is for - is there an explanation somewhere?

Thanks in advance
Regards
Max_admin Max_admin 20 Apr, 2017
Hi ctrlmedia,

How do you know the value is passed correctly ? try to add this in the checkbox label:
{var:ListIssues.row.Issues.completed}


Does it show 1 ? if it does then I will need to check the page.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ct ctrlmedia 20 Apr, 2017
Hi Max,
Thanks for the quick response.
Yeah they all have zero apart from the ones I want to be checked where they are 1's (but not checked)

I will PM you the page?

Regards
Mark
Max_admin Max_admin 20 Apr, 2017
Hi ctrlmedia,

Ok, this will need a workaround in order to get the box checked.

In your checkbox "Extra attributes", please write this:
{fn:php_fn_name}

You will then need to create a PHP function and name it "php_fn_name" (or whatever).
In this function please use this code:

if($this->get("ListIssues.row.Issues.completed")){
echo "checked";
}


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin Max_admin 20 Apr, 2017
Another note, the value of the checkbox should be set to "1", it should not change.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ct ctrlmedia 21 Apr, 2017
HI Max,
I have set the value to 1.
I have created the php function and added it to the "extra attributes" box but it is not working.
Looking at the source it adds {fn="php_fn_name}" to the input.

Thanks for helping.
Max_admin Max_admin 21 Apr, 2017
Hi ctrlmedia,

it should be : not =

 {fn:php_fn_name}

And "php_fn_name" should be the name of the php function.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ct ctrlmedia 21 Apr, 2017
Hi Max,
That is what I have put in but that is not what is being shown when I view the source code.
(although 'checked' is what should appear)

I have added images to better describe.

Regards
Max_admin Max_admin 21 Apr, 2017
Hi ctrlmedia,

And what is the name of your php function ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ct ctrlmedia 21 Apr, 2017
php_fn_name - image attached.
Regards
Max_admin Max_admin 21 Apr, 2017
Hi ctrlmedia,

Ok, please send me a message using the Contact us page to get a patch file to test this.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ct ctrlmedia 21 Apr, 2017
Hi Max,
I have just done this.
Regards
Mark
Max_admin Max_admin 21 Apr, 2017
Hi Mark,

Just sent it!

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ct ctrlmedia 21 Apr, 2017
That seems to have done the trick Max.
Was it an issue with the way it output the extra attribute function?
Regards
Max_admin Max_admin 21 Apr, 2017
Answer
1 Likes
Hi Mark,

Yes, that's the most updated file and should be included in the new update.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.